Web storage is a new feature of HTML5 that allows data to be stored in a local browser, enabling easy operation of the data and the ability to store up to 5M.
There are two types of WEB storage: Sessionstorage and Localstorage. Sessionstorage saves data when the browser is open and the data is discarded when the page is closed. Localstorage saved data will not disappear as the Web page and browser close, it will be saved locally, when the Web page opens again, the data still exists.
There are four common methods for WEB storage:
GetItem ("Key"); Get the data
SetItem ("Key", value); Storing data
RemoveItem ("Key"); Delete data
Clear (); Bulk Delete Data
Application Examples:
1 <!DOCTYPE HTML>2 <HTML>3 <HeadLang= "en">4 <MetaCharSet= "UTF-8">5 <title></title>6 </Head>7 <Body>8 <inputtype= "text"ID= "Text1">9 <inputtype= "button"value= "Session_set"onclick= "save_session ()">Ten <inputtype= "button"value= "Session_get"onclick= "load_session ()"> One <BR> A <inputtype= "text"ID= "Text2"> - <inputtype= "button"value= "Local_set"onclick= "save_local ()"> - <inputtype= "button"value= "Local_get"onclick= "load_local ()"> the <Script> - functionsave_session () { - varTarget=document.getElementById ("Text1"); - varStr=Target.value; + Sessionstorage.setitem ("Text_message", str); - } + functionload_session () { A varStr=Sessionstorage.getitem ("Text_message"); at alert (str); - } - functionsave_local () { - varTarget=document.getElementById ("Text2"); - varStr=Target.value; - Localstorage.setitem ("Text_message", str); in } - functionload_local () { to varStr=Localstorage.getitem ("Text_message"); + alert (str); - } the </Script> * </Body> $ </HTML>
Link Address: http://1.huizit1.applinzi.com/HTML5/web_storage/webstorage.html
Web Storage for new features of HTML5