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.