Advertisement
Guest User

Untitled

a guest
Dec 1st, 2012
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Homepage:
  2. <!DOCTYPE HTML>
  3. <html>
  4. <head>
  5. <script>
  6. function showStuff() {
  7.     if (localStorage["name"]) {                                        //Only when the text exist,
  8.         document.getElementById("type").innerHTML = localStorage["name"]   //Restore the text
  9.     }
  10. }
  11. window.onload = showStuff;       //Restore
  12. </script>
  13. </head>
  14. <body>
  15. <div id="type">blah</div>
  16. </body>
  17. </html>
  18.  
  19.  
  20. Form page:
  21. <!DOCTYPE HTML>
  22. <html>
  23. <head>
  24. <script>
  25. function submitform(){
  26.     var textbox = document.getElementsByName('name')[0];
  27.     value = textbox.value;
  28.     localStorage["name"] = value;   //save it in localStorage
  29. }    
  30. </script>
  31. </head>
  32. <body>
  33. Name: <input name="name"><br>
  34. <button onclick="submitform();">Submit</button>
  35. </body>
  36. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement