sava data and read data
localStorage.a=3
localStorage["a"]='apple'
localStorage["a"]//"apple"
localStorage.setItem('a','orange')
localStorage.a//"orange"
localStorage.getItem("a")//"orange"
localStorage.removeItem("a")
localStorage.getItem("a")//null
an example
<html>
<body>
<script type="text/javascript">
if (localStorage.a){
localStorage.a=Number(localStorage.a)+1;
} else {
localStorage.a=1;
}
document.write(localStorage.a)
</script>
<p>刷新页面会看到计数器在增长。</p>
<p>请关闭浏览器窗口,然后再试一次,计数器会继续计数。</p>
</body>
</html>