saveFavorite Behavior
Enables the object to persist data in a Favorite.
Syntax
XML N/A HTML <ELEMENT STYLE="behavior:url('#default#saveFavorite')" ID=sID> Scripting object.style.behavior = "url('#default#saveFavorite')" object.addBehavior ("#default#saveFavorite")
Possible Values
sID String that specifies a unique identifier for the object.
Members
Remarks
The saveFavorite behavior allows the current state of a page to be saved when the user adds the page to Favorites. When the user returns to the page through a shortcut or the Favorites menu, the state of the page is restored.
The saveFavorite behavior persists data across sessions, using one UserData store for each object. If two objects try to use the same attribute, both are persisted in the UserData store for each element. The saveFavorite UserData store is persisted in the Favorites INI file, which includes the URL of the page as well as the UserData store. When the page is loaded through a shortcut or Favorites, the data from the UserData store is loaded from the INI file, even if the user closes and reopens Microsoft® Internet Explorer.
For example, a page with several dynamically updated styles can save these updates using the onload and onsave events. The style values can be saved as attributes when onsave fires, and restored when onload fires.
To use the saveFavorite behavior, use a META tag that identifies the type of persistence.
<META NAME="save" CONTENT="favorite">The required STYLE can be set inline or in the document header, as follows:
<STYLE> .saveFavorite {behavior:url(#default#savefavorite);} </STYLE>An ID is optional for saveFavorite, but including one improves performance.
The saveFavorite behavior is available as of Microsoft® Internet Explorer 5, in the Microsoft® Win32® and Unix platforms.
Example
This example uses the saveFavorite behavior to persist information after the user saves the page as a favorite.
Sample Code
<HTML> <HEAD> <META NAME="save" CONTENT="favorite"> <STYLE> .saveFavorite {behavior:url(#default#savefavorite);} </STYLE> <SCRIPT> function fnSaveInput(){ 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>
Applies To
[ Object Name ] Platform Version Win16: Win32: Mac: Unix: WinCE: Version data is listed when the mouse hovers over a link, or the link has focus. A, ACRONYM, ADDRESS, AREA, B, BIG, BLOCKQUOTE, BUTTON, CAPTION, CENTER, CITE, CODE, DD, DEL, DFN, DIR, DIV, DL, DT, EM, FONT, FORM, Hn, HR, I, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=hidden, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, KBD, LABEL, LI, LISTING, MAP, MARQUEE, MENU, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, Q, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TEXTAREA, TT, U, UL, VAR, XMP
See Also
dhtml behaviors, persistence overview
Did you find this topic useful? Suggestions for other topics? write us!
© 1999 microsoft corporation. all rights reserved. terms of use.