saveHistory Behavior

DHTML, HTML, & CSS

saveHistory Behavior


Enables the object to persist data in the browser history.

Syntax

XMLN/A
HTML<ELEMENT STYLE="behavior:url('#default#saveHistory')" ID=sID>
Scriptingobject.style.behavior = "url('#default#saveHistory')"
object.addBehavior ("#default#saveHistory")

Possible Values

sID String that specifies a unique identifier for the object.

Members

Remarks

The saveHistory behavior saves the current state of the page when the user navigates away from the page. When the user returns to the page by pressing the back or forward button, the values are restored.

The saveHistory behavior persists only for the current session. When the user navigates away from the page containing the saveHistory behavior, the data is persisted in a UserData store. The saveHistory behavior uses one UserData store for the entire document. Thus, if two elements write the same attribute, the first is overwritten by the second. The UserData store is saved in an in-memory stream and is not saved to disk. Therefore, it is not available after the user closes Microsoft® Internet Explorer.

For example, a page with several dynamically updated styles might save these updates using the onload and onsave event handlers. The style values can be saved as attributes when onsave fires, and restored when onload fires.

To use the saveHistory behavior, use a META tag that identifies the type of persistence.

   <META NAME="save" CONTENT="history">

The required STYLE can be set inline or in the document header, as follows:

   <STYLE>
      .saveHistory {behavior:url(#default#savehistory);}
   </STYLE>

An ID is optional for saveHistory, but including one improves performance.

The saveHistory behavior is available as of Microsoft® Internet Explorer 5, in the Microsoft® Win32® and Unix platforms.

Example

This example uses the saveHistory behavior to persist information after the user leaves and subsequently returns to the page.

Sample Code

<HTML>
<HEAD>
<META NAME="save" CONTENT="history">
<STYLE>
   .saveHistory {behavior:url(#default#savehistory);}
</STYLE>
</HEAD>
<BODY>
<INPUT class=saveHistory type=text id=oPersistInput>
</BODY>
</HTML>
This feature requires Internet Explorer 5 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
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 behaviorsInternet Link, persistence overviewInternet Link

Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.