View difference between Paste ID: SurbLhWZ and NnzwTBHJ
SHOW: | | - or go back to the newest paste.
1
Homepage:
2
<!DOCTYPE HTML>
3
<html>
4
<head>
5
<script>
6
function showStuff() {
7-
    if (localStorage["stuff"]) {                                        //Only when the text exist,
7+
    if (localStorage["name"]) {                                        //Only when the text exist,
8-
        document.getElementById("type").innerHTML = localStorage["stuff"]   //Restore the text
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>