Description
Fires immediately after the browser loads the given object.
Remarks
The browser loads applications, embedded objects, and images as soon as it encounters the APPLET, EMBED, and IMG elements during parsing. This means that the onload event for these objects occurs before the browser parses any subsequent elements. To ensure that an event handler receives the onload event for these elements, you must place the SCRIPT element that defines the event handler before the element and use the onload attribute in the element to set the handler.
The onload attribute of the BODY element sets an onload event handler for the window. Setting an onload event handler for the window object by any other means will override the handler set using the onload attribute if the handlers are in the same script language.
This event will not bubble. Events that do not bubble can only be handled on the individual object that fired the event.
Examples
The following JScript example is an onload event handler for the window.
<SCRIPT FOR=window EVENT=onload LANGUAGE="JScript">
window.status = "Page is loaded!";
</SCRIPT>
The following JScript example sets an onload event handler for an IMG element. The handler uses the event object to retrieve the URL of the image.
<SCRIPT LANGUAGE="JScript">
function imageLoaded()
{
window.status = "Image \"" + window.event.srcElement.src + "\" is loaded";
}
</SCRIPT>
<IMG SRC="sample.gif" onload="imageLoaded()">
Applies To
APPLET, EMBED, FRAMESET, IMG, LINK, SCRIPT, STYLE, window