How can I get an event to fire every time localStorage is updated in Safari 5+?

后端 未结 3 515
遥遥无期
遥遥无期 2020-12-18 23:58

I have tried to follow the examples on the Safari Developer Site.

The documentation suggests adding an event listener like so:

window.addEventListene         


        
3条回答
  •  清酒与你
    2020-12-19 00:37

    After investigating further (and with the help from a friend) I discovered that the storage_handler method is called not when the value of a localstorage value changes on the page in my current window or tab, but when it changes in another tab.

    For example, if I have the two tabs open, and have controls in the pages in each tab to change localstorage settings, then when I hit the control in the first tab, the storage_handler method is called in the other tab.

提交回复
热议问题