JSFiddle - React, Tailwind, and code Playground
JavaScript
function spracuj(e) {
alert("Event:"+e.newValue);
}
document.onstorage = spracuj;
document.onstoragecommit = spracuj;
if (window.addEventListener) {
addEventListener('storage',spracuj,false);
}
else if (window.attachEvent) {
attachEvent('onstorage',spracuj);
}
var val = localStorage.getItem("test");
if (val==null){
var a = prompt("Zadej hodnotu");
localStorage.setItem("test", a);
} else {
alert("Ulozena hodnota: "+val);
localStorage.removeItem("test");
}