forked from skjApp/HTML5-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSessionStorage.htm
More file actions
33 lines (25 loc) · 766 Bytes
/
SessionStorage.htm
File metadata and controls
33 lines (25 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE HTML>
<html>
<head>
<title>Example - Session Storage</title>
</head>
<body>
<input id = "text1" type = "text"/ value = "String to be stored">
<input id = "button1" type = "button" value = " Store Data " onclick="store()"> </input>
<input id = "button2" type = "button" value = "Retrieve Data" onclick="retrieve()"> </input>
<script type = "text/javascript">
function store()
{
var text1 = document.getElementById('text1') ;
var data = text1.value ;
sessionStorage.setItem('testKey',text1.value) ;
alert('Stored Data : ' + data) ;
}
function retrieve()
{
var data = sessionStorage.getItem('testKey') ;
alert('Retrieved Data : ' + data) ;
}
</script>
</body>
</html>