-1
我想知道是否可以在其他頁面上使用本地存儲。我需要在另一個頁面中使用點擊。不知道該怎麼做,或者甚至有可能。如果你能幫我解決問題,那就太好了。它仍然是我的學校項目。本地存儲HTML5
非常感謝提前。
function clickCounter() {
if(typeof(Storage) !== "undefined") {
if (localStorage.clickcount) {
localStorage.clickcount = Number(localStorage.clickcount)+1;
} else {
localStorage.clickcount = 1;
}
document.getElementById("result").innerHTML = "You have clicked the button " + localStorage.clickcount + " time(s).";
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support web storage...";
}
}
<div id="result" style ="color: white;"></div>
<p><button onclick="clickCounter()" type="button">Click me!</button></p>
是的,你可以簡單地通過調用'localStorage.clickcount'來使用它。或者我錯了? – Zee
檢查它:http://stackoverflow.com/questions/19238404/firefox-localstorage-how-to-access-it-across-all-tabs/19238846#19238846 –