<! DOCTYPEHTML> <HTML> < Head> <Metacharset="Utf-8"> <title> Local Storage localstorage </title> </ Head> < Body> <inputid="MSG"type="Text"/> <inputid="SetData"type="button"value="Save Data"/> <inputid="GetData"type="button"value="Get Data"/> <Scripttype="Text/javascript">window. onload =function() {Alert ("When you close this page or close the browser, the data saved in the localstorage disappears, which means that when you reopen the page, you click on the data to get the data." "//First get 3 input elements in the bodyvarmsg =Document. getElementById ("MSG");varGetData =Document. getElementById ("GetData");varSetData =Document. getElementById ("SetData"); Setdata.onclick =function()//Deposit Data {if(Msg.value) {Sessionstorage. SetItem ("Data", Msg.value); Alert"Information has been saved in the data field"); }Else {Alert ("Information cannot be empty"); }} Getdata.onclick =function()//Get Data {varmsg =Sessionstorage. GetItem ("Data");if(msg) {Alert ("The value in the data field is:"+ msg); }Else {Alert (The data field has no value. "); }}} </Script> </ Body> </HTML>