Pregunta

I'm developing firefox extension and going to save local data in localStorage. So I testing my extension on local saved web page.

window.content.localStorage.setItem('name', 'Hello World!');

And window.content.localStorage.getItem('name') return correct string. But when I reopened this testing page window.content.localStorage.getItem('name') returns 'null'. Why? It's because I'm using local page?

¿Fue útil?

Solución

Different browsers currently treat file: urls differently for localStorage.

This means that if you are just creating a file on your computer and opening it directly, you will have different results depending on the browser you are using.

I believe this was changed in Firefox 8, so if you use 8 or higher it should work for you. Other browsers I am not sure about.

Edit: Is "localStorage" in Firefox only working when the page is online? seems to confirm that FF3-8 will not work how you are doing it.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top