Listen for localStorage.setItem on same Window (FireFox & IE)

时间:2019-01-09 22:27:25

标签: javascript local-storage addeventlistener dom-events

I found this thread that answers partially:

Listen for changes with localStorage on the same window

Although it works in Chrome, I still wasn't able to figure out how to work on Firefox or IE.

1 个答案:

答案 0 :(得分:0)

Storage接口在受其影响的全局对象上发出storage事件。

window.addEventListener("storage", function () {
    // your code
}, false);

使用setItem时也会触发此事件。