-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
30 lines (27 loc) · 1.29 KB
/
test.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
<!DOCTYPE html>
<html>
<head>
<title>localStorageEvent test</title>
<script type="text/javascript">
function onstorage(event) {
alert([event.key, event.oldValue, event.newValue, event.url, event.storageArea].join('\n'));
}
function insertValue() {
var value = prompt('Valeur :');
if(value)
localStorage.setItem('data', value);
}
function readValue() {
alert(localStorage.getItem('data'));
}
window.onload = function() {
window.addEventListener('storage', onstorage, false);
}
</script>
</head>
<body>
<button onclick="insertValue();">Inserer une valeur</button>
<br>
<button onclick="readValue();">Lire la valeur</button>
</body>
</html>