如何刪除 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