views:

105

answers:

1

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.

+3  A: 

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.

Jonathan Lonowski
Yeah, i think thats it... i was running it locally ill try uploading it, but reading this seems like thats what it is
Oscar Godson