LocalStorage doesn't start from multiple pages
I have three separate pages / tabs.
1) PageA sets localstorage with key "data" - works
2) PageB gets a local storage of key "data" - it works
3) PageC set localstorage with key "data" - works
4) PageB gets local storage with key "data" DOES NOT WORK listener does not start
(I tried localStorage.clear before setting "data" to no avail. Using a different "key" to no avail)
pageA
localStorage.setItem("data", "first");
pageB
//set listener
if (window.addEventListener) {
window.addEventListener("storage", handler, false);
}
else {
window.attachEvent("onstorage", handler);
};
function handler(e) {
//works form pageA not pageC. Nothing is in console.
console.log(localStorage.getItem("data"));
}
pageC
localStorage.setItem("data", "second");
+3
source to share
No one has answered this question yet
See similar questions:
or similar: