
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML onLoad Event Attribute
The HTML onload event attribute is triggered when an object has been loaded in an HTML document.
Syntax
Following is the syntax −
<tagname onload=”script”></tagname>
Let us see an example of HTML onload event Attribute−
Example
<!DOCTYPE html> <html> <head> <style> body { color: #000; height: 100vh; background-color: #FBAB7E; background-image: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%); text-align: center; padding: 20px; } </style> <script> function get() { alert("Hi! you just refresh the document."); } </script> </head> <body onload="get()"> <h1>HTML onload Event Attribute Demo</h1> <p style="color:#db133a;">Now try to refresh this document.</p> </body> </html>
Output
Now try to reload the document to observe how onload event attribute works.
Advertisements