如何删除网络存储?
在本地计算机上存储敏感数据可能很危险,并且可能会留下安全漏洞。会话终止后,浏览器会立即删除会话存储数据。
要清除本地存储设置,您需要调用localStorage.remove('key');。其中“键”是您要删除的值的键。如果要清除所有设置,则需要调用localStorage.clear()方法。
<!DOCTYPE HTML><html>
<body>
<script>
localStorage.clear();
//重置点击数。
if( localStorage.hits ){
localStorage.hits = Number(localStorage.hits) +1;
} else{
localStorage.hits = 1;
}
document.write("总命中:" + localStorage.hits );
</script>
<p>Refreshing the page would not to increase hit counter.</p>
<p>Close the window and open it again and check the result.</p>
</body>
</html>
以上是 如何删除网络存储? 的全部内容, 来源链接: utcz.com/z/331350.html