Appweb2.js
/**
* Created by HP on 2015/8/30.
*/
functionSavestorage (ID) {
Vardata =Document.getElementById (ID).Value
VarTime =New Date ().GetTime ();
Localstorage.SetItem (Timedata);
Alert"Data is stored");
Loadstorage (' msg ');
}
functionLoadstorage (ID) {
Varresult ="<table border= ' 1 ' >";
ForVari =0;i<Localstorage.Lengthi++) {
VarKey =Localstorage.Keyi);
VarValue =Localstorage.GetItem (Key);
VarDate =New Date ();
Date.SetTime (Key);
Result + ="<tr><td>" +Value+"</td><td>" +Date+"</td></tr>";
}
Result + ="</table>";
Vartarget = document. getElementById (ID);
Target. InnerHTML = result;
}
function Clearstorage () {
Localstorage. Clear ();
alert (" data deleted ");
loadstorage (' msg ');
}
Web2.html
<! DOCTYPEHtml>
<Html>
<Headlang="EN">
<Metacharset="UTF-8">
<Title></Title>
<ScriptSrc="Appweb2.js"></Script>
</Head>
<Body>
<PId="MSG"></P>
<TextAreacols="60"Rows="10"Id="Memo"></TextArea>
<Br/>
<InputType="Button"Value="Append Data"onclick="Savestorage (' Memo ')";
<input type=value= " " Onclick= ' msg ') ;
</body ;
</html ;
Simple Web Message Book