IE provides a store that can persist user data, called UserData, from IE5.0 to support. Up to 128K per data, up to 1M per domain. This persisted data is stored in the cache and will persist if the cache is not cleaned up.
<div style= "Behavior:url (#default #userdata)" id= "box" ></div>
addevent (window, ' Load ', function () {
var box = document.getElementById (' box ');
Box.setattribute (' name ', encodeURIComponent (' Li Tinghui '));
Box.save (' BookInfo ');
Box.removeattribute (' name ');//Delete userdate
Box.save (' BookInfo ');
Box.load (' BookInfo ');
Alert (decodeuricomponent) (Box.getattribute (' name '));
});
PS: This data file is also stored in the cookie directory, as long as the cookie can be erased. If you specify an expiration date, it is automatically deleted after expiration, and is persisted if not specified.
Web Storage
In a newer version of the browser, JavaScript provides sessionstorage and globalstorage. In HTML5, Localstorage is provided to replace the globalstorage. The minimum version of the browser is: ie8+, firefox3.5+, Chrome 4+ and opera10.5+.
PS: Because these three browser version requirements are high, we simply understand in Firefox, interested in the keyword search query.
Storing and retrieving by methods
Sessionstorage.setitem (' name ', ' Li Tinghui ');
Alert (Sessionstorage.getitem (' name '));
Storing and retrieving by attributes
Sessionstorage.book = ' Li Tinghui ';
alert (Sessionstorage.book);
Delete Storage
Sessionstorage.removeitem (' name ');
PS: Because Localstorage replaces Globalstorage, the latest version of Firefox, opera and Chrome is not supported.
Storing and retrieving by methods
Localstorage.setitem (' name ', ' Li Tinghui ');
Alert (Localstorage.getitem (' name '));
Storing and retrieving by attributes
Localstorage.book = ' Li Tinghui ';
alert (Localstorage.book);
Delete Storage
Localstorage.removeitem (' name ');
PS: These three objects are permanently saved in the cache, and can only be invalidated by manual deletion or by cleaning the browser cache. There are also some restrictions on capacity, mainly looking at browser differences, firefox3+, ie8+, Opera for 5m,,chrome and Safari for 2.5M.