admin管理员组文章数量:1426486
I am only concerned with mozilla's use of localStorage. When i store strings into localStorage
example:
on tab A, I insert:
localStorage["item"] = "hello";
on tab B, I request the same item using
localStorage.getItem("item");
I cannot access this item for some reason in Tab B if i set the the value in Tab A, however i have used the same code in Google Chrome before and it has shown Global characteristics.. why does it not work in Mozilla Firefox the same way?? Other stackoverflow threads have said to use globalStorage but that is a deprecated method according to documentation.
Thanks,
Aiden
I am only concerned with mozilla's use of localStorage. When i store strings into localStorage
example:
on tab A, I insert:
localStorage["item"] = "hello";
on tab B, I request the same item using
localStorage.getItem("item");
I cannot access this item for some reason in Tab B if i set the the value in Tab A, however i have used the same code in Google Chrome before and it has shown Global characteristics.. why does it not work in Mozilla Firefox the same way?? Other stackoverflow threads have said to use globalStorage but that is a deprecated method according to documentation.
Thanks,
Aiden
Share Improve this question edited Oct 8, 2013 at 14:33 therealjeffg 5,8301 gold badge25 silver badges24 bronze badges asked Oct 8, 2013 at 3:07 AidenAiden 3996 silver badges19 bronze badges 2- 2 Are tab A and tab B open to pages on the same origin? (i.e., same protocol and domain name)? – apsillers Commented Oct 8, 2013 at 14:46
- hey they are different origins. thanks – Aiden Commented Oct 10, 2013 at 21:34
1 Answer
Reset to default 4What you may try is to set the localStorage
value as:
localStorage.setItem("item", "hello");
or
localStorage.item = "hello"
According to the specification all documents with the same origin share the same localStorage
data (regardless of the origin of the scripts that actually access localStorage
). They can read each other’s data. And they can overwrite each other’s data. But documents with different origins can never read or overwrite each other’s data (even if they’re both running a script from the same third-party server).
This means that you should be able to access the same localStorage
date from different tabs.
本文标签: javascriptFirefox localStorage how to access it across all tabsStack Overflow
版权声明:本文标题:javascript - Firefox localStorage how to access it across all tabs? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745430321a2658295.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论