-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
50 lines (49 loc) · 1.69 KB
/
index.html
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>object-localstorage</title>
<link rel="stylesheet" href="">
<script src="src/object-localstorage.js"></script>
<!--<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">-->
<style>
body {
padding: 50px;
}
input {
margin-top: 20px;
}
#result {
margin-top: 10px;
font-size: 20px;
}
</style>
</head>
<body>
<h1>object-localstorage</h1>
<div class='input-group'>
<input class='form-control' id='inputToStorage' type="text" placeholder='要存入localstorage的字段'>
<input class='form-control' id='inputToStorageValue' type="text" placeholder='字段的值'>
<button class='btn btn-default' id='setItem'>存入localstorage</button>
</div>
<input class='form-control' id='inputFromStorage' type="text" placeholder='要从localstorage取出的字段'><button class='btn btn-default' class='btn btn-default' id='getItem'>从localstorage取出</button>
<p id='result'></p>
<script>
/**
* [Store description]
* objectLocalstorage.setItem(object.field, value);
* objectLocalstorage.getItem(object.field);
*/
document.getElementById('setItem').addEventListener('click', function () {
var key = document.getElementById('inputToStorage').value;
var value = document.getElementById('inputToStorageValue').value;
objectStorage.setItem(key, value);
});
document.getElementById('getItem').addEventListener('click', function () {
var key = document.getElementById('inputFromStorage').value;
var value = objectStorage.getItem(key);
document.getElementById('result').innerHTML = key + ' : ' + value;
});
</script>
</body>
</html>