标签:html5 本地 缓存 本地缓存 localstorage
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>访问计数</title>
</head>
<body>
<div id="counter_div"></div>
</body>
</html>
<script type="text/javascript">
// 递增localStorage计数
if (localStorage.counter == null) {
localStorage.counter = 1;
} else {
localStorage.counter++;
}
// 显示计数
var counter_div = document.getElementById("counter_div");
counter_div.innerHTML = localStorage.counter;
</script>
标签:html5 本地 缓存 本地缓存 localstorage
原文地址:http://jinliang.blog.51cto.com/8981814/1616222