HTML5 storage --Web Storage (localStorage and the sessionStorage)

A, localStorage object temporary storage API 
methods: 
. 1, localStorage.setItem (Key, value) --- content setting storage 
2, localStorage.getItem (key) --- acquires storage content of 
3, localStorage.removeItem (key) --- delete the stored content 
4, localStorage.clear () --- disposable clear all the key
5, localStorage.length-- acquired number of stored content 
6, localStorage.key or localStorage [key] - acquiring a storage content 

--- localStorage: no capacity of storage time of about 2-5Mb, stored string. 
sessionStorage ---: 
1) failure (refresh no problem, close the page is gone) varying storage capacity at the end of the session page. Many browsers do not limit different pages can not share the same url sessionStorage data (only in its own tab); 
2) storage capacity exceeds the limit, an exception is thrown QutotaExceededError, stored value should avoid using try catch uncaught exception; 
3) only You can store strings, note type conversion.

Guess you like

Origin www.cnblogs.com/rickdiculous/p/11443743.html