Reputation: 32776
I'm not sure why, as i've done this before and it worked fine, and i'm thinking it might be because of a browser issue/bug:
localStorage.setItem('foo', 'bar')
alert(localStorage.getItem('foo'));
I'm in Firefox 3.6.6 and it alerts "bar" but if I do:
//localStorage.setItem('foo', 'bar')
alert(localStorage.getItem('foo'));
I get NULL. It should return bar still as it's in my storage.
Also, this is just a web page that it's running on.
Upvotes: 3
Views: 4909
Reputation: 123563
Are you running the script locally via file:
?
If so, Firefox doesn't appear to allow localStorage
entries to live beyond unload when file:
access is used.
For more info, you may want to look at the question: Is “localStorage” in Firefox only working when the page is online? It's a little dated, but still seems to be applicable.
Upvotes: 7