Share via


onsave Event

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

Fires from a persisted element when the Web page is saved or bookmarked, or when the user navigates away from the page.

Syntax

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

Event Information

Bubbles No
Cancels Yes
To invoke
  • Save the Web page.
  • Bookmark the Web page.
  • Navigate to another page.
Default action Initiates any action associated with this script.

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 onsave event for a persistence behavior.

<HTML>
<HEAD>
<META NAME="save" CONTENT="favorite">
<STYLE>
   .saveFavorite {behavior:url(#default#savefavorite);}
</STYLE>
<SCRIPT>
   function fnSaveInput(){
      alert("The onsave event fired.");
      oPersistInput.setAttribute("sPersistValue",oPersistInput.value);
   }
   function fnLoadInput(){
      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/onsave_1.htm

Applies To

saveFavorite, saveHistory, saveSnapshot