存储事件未触发 [英] Storage event not firing

查看:86
本文介绍了存储事件未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

附加活动:

$(window).on("storage", function (e) {
   //callback not getting hit
});

尝试触发事件:

localStorage.setItem("test", "123");

我打开两个标签,同时收听存储事件。我可以在两个选项卡上看到localStorage正确更新。但是,当我在一个选项卡上更改localStorage时,另一个选项卡永远不会触发该事件。有什么想法?

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?

在Chrome / Firefox上试过。域格式为 https://www.xxx.yyy.zzz

Tried on Chrome/Firefox. Domain format is https://www.xxx.yyy.zzz.

推荐答案

问题是由 document.domain 覆盖代码引起的。删除 document.domain setter后,事件正常工作。

Problem was caused by document.domain overriding in code. After I removed the document.domain setter, events worked correctly.

似乎这是由Chrome中的错误引起的。

Seems this is caused by a bug in Chrome.

https://bugs.chromium.org/p/chromium/issues/detail ?id = 136356& q = label%3AOWP- Standards-Compatibility& colspec = ID%20Pri%20M%20Stars%20ReleaseBlock%20Cr%20Status%20Owner%20Summary%20OS%20Modified

这篇关于存储事件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆