Localstorage:
1, Localstorage extended the 4K limit of cookies
2, Localstorage will be able to store the first request data directly to the local, this is equivalent to a 5M size for the front-end page of the database, compared to the cookie can save bandwidth, but this is only in the higher version of the browser is supported
1. Determine if the browser supports localstorage;
if (! Window.localstorage)
{Alert ("browser supports Localstorage"); return false;} else{//main logic business}
2. Write (Save)
var storage=window.localstorage; Write a field storage["a"]=1; Write b field storage.a=1; Write C field Storage.setitem ("C", 3);
3. Output (take)
The first method reads var a=storage.a; Console.log (a); The second method reads var b=storage["B"]; Console.log (b); The third method reads the Var c=storage.getitem ("C");
Removal of 4.localStorage
All contents of 1.localStorage clear: storage.clear ();
2. Clear the corresponding LocalStorage:storage.removeItem ("a");
See more: Localstorage Use summary
The Localstorage of the Web