document.onLoad

JavaScript1.0+, JScript1.0+ Nav2+, IE3+ Syntax

onLoad="command"

Description

The onLoad event handler of the Document object is fired when the page has finished loading in that particular window instance. This event handler actually belongs to the Window object but is accessible through the Document object.

Note

The onLoad event in the <body> of a document that is loaded in a frame will fire before an event loaded in the <frameset> tag that loaded the document.

Example

The sample of code in Listing 7.151 pops up an alert box when the page has finished loading using the onLoad event handler.

Listing 7.151 Handle the Load Event with the onLoad Event Handler
<body onLoad='alert("The document has completely loaded.")'>

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.