Client memory
Several forms of client storage:
Web Memory
Cookies
IE UserData
Offline applications
Web Database
File System API
20.1 Localstorage and Sessionstorage
20.1.1 Storage expiration and scope
The difference between Localstorage and Sessionstorage is that the storage has a different validity period and scope.
The scope of the Localstorage is limited at the document source level.
Document Source: protocol hostname port determines the same document source
Source documents can share the same localstorage, and can even change and overwrite localstorage.
The scope of Localstorage is limited by different browser vendors.
Source documents can share the same sessionstorage, the scope is limited to the form, and the form here refers to the top-level form.
<iframe> of homologous document sources can share sessionstorage.
Test whether the browser supports this feature:
<strong>function Test () {var a = Window.localstorage;if (a) {alert ("Your browser supports Localstorage");} else {Ale RT ("Your browser Dosen ' t support Localstorage");}} </strong>
20.1.2 Storage API
Manipulating storage objects and properties
<strong>localstorage.setitem ("UserName", "Michael"); Localstorage.getitem (); Localstorage.removeitem (); Localstorage.delete (); Localstorage.clear ();</strong>
20.1.3 Storage Events
local storage for HTML5. A storage event is also provided . Ability to listen for changes to key-value pairs, such as the following:
if (Window.addeventlistener) {
Window.addeventlistener ("Storage", handle_storage,false);
}else if (window.attachevent) {
Window.attachevent ("Onstorage", handle_storage);
}
function Handle_storage (e) {
if (!e) {e=window.event;}
Showstorage ();
}
20.2 Cookies
20.2.1 Cookie Expiration and scope
Not to be continued
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
JavaScript authoritative guide Section 20 client memory