日期:2014-05-17  浏览次数:20658 次

有关清除HTML5 localStorage信息的问题
目前在学习HTML5,WEB存储,代码如下
<!DOCTYPE HTML>
<html>
<body>

<script type="text/javascript">

if (localStorage.pagecount)
{
localStorage.pagecount=Number(localStorage.pagecount) +1;
}
else
{
localStorage.pagecount=1;
}
document.write("Visits: " + localStorage.pagecount + " time(s).");

</script> 

<p>刷心页面会看到计数器在增长。</p>

<p>请关闭浏览器窗口,然后再试一次,计数器会继续计数。</p>
</body>
</html>

请问如何清楚localStorage的记录,让计数从新开始,我清楚历史记录,高速缓存,但计数还是累加

------解决方案--------------------
var storage = window.localStorage;
storage.pageLoadCount = 0;