I want to listen for changes that are happening in the localStorage API on the same page (Not in multiple tabs like the spec says).
I am currently using this code:
var storageHandler = function () {
alert('storage event 1');
};
window.addEventListener("storage", storageHandler, false);
localStorage.setItem('foo', 'bar');
Does anyone know a vanilla JavaScript way to listen to events on localStorage on one page (no jQuery)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…