- Attribute of
- HTML Body Tag: Master The Most Important HTML Element Now
- What does
- Fires a script when the page has finished loading.
onLoad attribute is an event handler that instructs the browser to run a script when the visitor loads the page. This is commonly used to forward the visitor to another page, but can be used to trigger pop-up boxes, or execute a script based on the user’s browser version.
Points to be aware of
body event handlers act on the browser window, and the script will only be executed once the page is completely finished loading. Because of this,
onLoad can’t be used to change the size or properties of the browser window. The opposite command,
onUnload, often yields more reliable results than
Browser Support for onLoad