Execute a JavaScript when a page is finished loading:
The onload event occurs when an object has been loaded.
onload is most often used within the <body> element to execute a script once a web page has completely loaded all content (including images, script files, CSS files, etc.).
In HTML:
In JavaScript:
| Parameter | Description |
|---|---|
| SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs |
![]()
The onload event is supported in all major browsers.
onload on <img>
Alert "Image is loaded" immediately after an image has been loaded.
Event Object
Your message has been sent to W3Schools.