HTML onloadEvent Attribute
Example
Run JavaScript after the document has finished loading:
<body onload="load()">
Try it Yourself »
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the onload event attribute.
Definition and Usage
The onload attribute triggers when the document object has finished loading.
The onload attribute is commonly used within the <body> element to execute a specified script after the page has fully loaded (including images, scripts, CSS files, etc.).
Differences between HTML 4.01 and HTML5
None。
Syntax
<element onload="script">
Attribute Values
| Value | Description |
|---|---|
| script | Specifies the script to be executed when the onload event is triggered. |
HTML Event Attributes Other Extensions