1 functionsavestorage (id) {2 vardata =document.getElementById (id). value;3 varTimeNow =NewDate ();4 Localstorage.setitem (timenow,data);5Localstorage.setitem (timenow+1, timenow);6Loadstorage (' msg '));7 }8 functionloadstorage (id) {9 varresult = ' <table border = ' 1 ' > ';Ten for(vari=0,j=1;i<localstorage.length;i+=2,j++) one { a varKey =Localstorage.key (i); - varValue =Localstorage.getitem (key); -Result + = ' <tr><td> ' +j+ ' </td><td> ' +value+ ' </td><td> ' +localstorage.getitem ( Key+1) + ' </td></tr> '; the } -Result + = ' </table> '; - vartarget =document.getElementById (id); -target.innerhtml =result; + } - functionclearstorage (id) { + localstorage.clear (); aAlert ("date deleted"); at}
View Code
1 <!DOCTYPE HTML>2 <HTML>3 <HeadLang= "en">4 <MetaCharSet= "UTF-8">5 <title>Simple note</title>6 <Scripttype= "text/javascript"src= "comment.js"></Script>7 </Head>8 <Body>9 <H1>Add note</H1>Ten <textareaID= "dome"cols= "$"rows= "2"></textarea><BR/><!--Text input Area - one <inputtype= "button"value= "save"onclick= "savestorage (' dome ');"> a <inputtype= "button"value= "load"onclick= "loadstorage (' msg ');"> - <inputtype= "button"value= "clear"onclick= "clearstorage (' msg ');"> - <H1>Note</H1> the <HR> - <PID= "msg"></P><!--Historical Input Area - - </Body> - </HTML>
Aa
1 F
functionsavestorage (id) {vardata =document.getElementById (id). value; varTimeNow =NewDate (); Localstorage.setitem (timenow,data); Localstorage.setitem (timenow+1, timenow); Loadstorage (' Msg ');}functionloadstorage (id) {varresult = ' <table border = ' 1 ' > '; for(vari=0,j=1;i<localstorage.length;i+=2,j++) { varKey =Localstorage.key (i); varValue =Localstorage.getitem (key); Result+ = ' <tr><td> ' +j+ ' </td><td> ' +value+ ' </td><td> ' +localstorage.getitem (key+1) + ' </td></tr> '; } result+ = ' </table> '; vartarget =document.getElementById (id); Target.innerhtml=result;}functionclearstorage (id) {localstorage.clear (); Alert ("date deleted");}
View Code
unctionsavestorage (id) {2 vardata =document.getElementById (id). value;3 varTimeNow =NewDate ();4 Localstorage.setitem (timenow,data);5Localstorage.setitem (timenow+1, timenow);6Loadstorage (' msg '));7 }8 functionloadstorage (id) {9 varresult = ' <table border = ' 1 ' > ';Ten for(vari=0,j=1;i<localstorage.length;i+=2,j++) one { a varKey =Localstorage.key (i); - varValue =Localstorage.getitem (key); -Result + = ' <tr><td> ' +j+ ' </td><td> ' +value+ ' </td><td> ' +localstorage.getitem ( Key+1) + ' </td></tr> '; the } -Result + = ' </table> '; - vartarget =document.getElementById (id); -target.innerhtml =result; + } - functionclearstorage (id) { + localstorage.clear (); aAlert ("date deleted"); at}
Use HTML5 's localstorage to make a memo.