如何删除 Web 存储?
在本地计算机上存储敏感数据可能是危险的,可能会留下安全漏洞。在会话终止后,会话存储数据将立即被浏览器删除。
要清除本地存储设置,你需要调用 localStorage.remove('key'); 其中'key'是你想要移除的值的键。如果你想清除所有设置,你需要调用 localStorage.clear() 方法。
<!DOCTYPE HTML>
<html>
<body>
<script>
localStorage.clear();
// Reset number of hits.
if( localStorage.hits ){
localStorage.hits = Number(localStorage.hits) +1;
} else{
localStorage.hits = 1;
}
document.write("Total Hits :" + 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>
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP