Partager via


onload Event

This topic documents a feature of Binary Behaviors, which are obsolete as of Internet Explorer 10.

Fires from a persistent element when the page reloads.

Syntax

Event Property object.onload = handler;
attachEvent object.attachEvent( "onload", handler);
Named script <SCRIPT FOR = object EVENT = onload>

Event Information

Bubbles No
Cancels Yes
To invoke Load the persistent Web page from a favorite or shortcut or through an Internet address.
Default action Initiates any action associated with this script. The onload event for behaviors overrides the onload event for DHTML objects.

Event Object Properties

Although event handlers in the DHTML Object Model do not receive parameters directly, a handler can query the event object for the following event properties.

Available Properties

srcElement Gets or sets the object that fired the event.

Refer to the specific event object for additional event properties.

Example

This example shows how to use the onload event for a persistence behavior.

<HTML>
<HEAD>
<META NAME="save" CONTENT="favorite">
<STYLE>
   .saveFavorite {behavior:url(#default#savefavorite);}
</STYLE>
<SCRIPT>
   function fnSaveInput(){
      oPersistInput.setAttribute("sPersistValue",oPersistInput.value);
   }
   function fnLoadInput(){
      alert("The onload event fired.");
      oPersistInput.value=oPersistInput.getAttribute("sPersistValue");
   }
</SCRIPT>
</HEAD>
<BODY>
<INPUT class=saveFavorite onsave="fnSaveInput()" onload="fnLoadInput()" 
    type=text id=oPersistInput>
</BODY>
</HTML>

Code example: https://samples.msdn.microsoft.com/workshop/samples/author/persistence/onload_1.htm

Applies To

saveFavorite, saveHistory