Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Homepage:
- <!DOCTYPE HTML>
- <html>
- <head>
- <script>
- function showStuff() {
- if (localStorage["name"]) { //Only when the text exist,
- document.getElementById("type").innerHTML = localStorage["name"] //Restore the text
- }
- }
- window.onload = showStuff; //Restore
- </script>
- </head>
- <body>
- <div id="type">blah</div>
- </body>
- </html>
- Form page:
- <!DOCTYPE HTML>
- <html>
- <head>
- <script>
- function submitform(){
- var textbox = document.getElementsByName('name')[0];
- value = textbox.value;
- localStorage["name"] = value; //save it in localStorage
- }
- </script>
- </head>
- <body>
- Name: <input name="name"><br>
- <button onclick="submitform();">Submit</button>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement