Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 1st, 2012  |  syntax: HTML 5  |  size: 0.75 KB  |  views: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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>