<body onLoad=””>

Attribute of
<body> HTML Tag
What does <body onLoad=""> do?
Fires a script when the page has finished loading.

The 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.

Example usage

<body onLoad="script"> 

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 onLoad.

Claire is seasoned technical writer, editor and HTML enthusiast.

Browser Support for onLoad