asp.net.ph

onload Event

DHTML Events


Fires immediately after the browser loads the object.

Syntax


Inline HTML <element onload = "handler" ... > All platforms
Event property object.onload = handler ECMA-262 Language Specification
Named script <script FOR=object EVENT=onload> Internet Explorer® only

Remarks


Bubbles No
Cancels No
To invoke Open a page in the browser to invoke this event for the document or any object within it.
Default action Loads the object for which the event is specified.

A load event occurs when the user agent finishes loading all content within the document's BODY, all frames within a FRAMESET, or an OBJECT element.

The onload attribute of the BODY object sets an onload event handler for the window. This technique of calling the window onload event through the BODY object is overriden by any other means of invoking the window onload event, provided the handlers are in the same script language.

In Internet Explorer®, the onload event can be applied to the following objects as well: APPLET, EMBED, and IMG.

As the browser loads applications, embedded objects, and images as soon as it encounters the objects during parsing, the onload event for these objects occurs before the browser parses any subsequent objects. To ensure that an event handler receives the onload event for these objects, the SCRIPT object that defines the event handler must be placed before the object and the onload attribute in the object used to set the handler.

Event Object Properties

While event handlers in the Document Object Model do not receive parameters directly, the handler can query the event object for data.

Event Object Properties


Example

This simple example demonstrates use of the onload event to notify when a page has loaded.

<script for=window event=onload>
alert("The page has loaded.");
</script>

 Show me 

The following example shows use of the onload event to trigger a function as the page loads.

 Show me 

Applies To

APPLET, EMBED, FRAMESET, IMG, LINK, OBJECT, SCRIPT, STYLE, window

See Also

onreadyStatechange, onunload




Contents
HTML Elements
HTML Element Attributes
CSS Attributes
DOM Objects
DOM Object Properties
DOM Events Reference
DOM Methods Reference
DOM Collections Reference
 

Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph