Attaching the event:
$(window).on("storage", function (e) { //callback not getting hit });
Trying to fire the event:
localStorage.setItem("test", "123");
I have two tabs open, both listening to the storage event. I can see the localStorage getting updated correctly on both tabs. However when I change localStorage on one tab, the other never fires the event. Any ideas?
Tried on Chrome/Firefox. Domain format is https://www.xxx.yyy.zzz
.
The storage event of the Window interface fires when a storage area ( localStorage ) has been modified in the context of another document.
Definition and Usage The storage event occurs when there is a change in the window's change area. Note: The storage event is only triggered when a window other than itself makes the changes.
StorageEvent is fired in different page with the same domain.
From MDN
The StorageEvent is fired whenever a change is made to the Storage object.
This won't work on the same page that is making the changes — it is really a way for other pages on the domain using the storage to sync any changes that are made。
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With