Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is "localStorage" in Firefox only working when the page is online?

So I'm toying around with HTML 5 and the localStorage and I'm noticing that my values only get stored when I run the page in Firefox on the local host (i.e. http://127.0.0.1:8000/test/index.html), but when I run the file locally (file:///C:/test/index.html) my values don't get stored. Safari 4 has no problems with both setups. So does anybody know if this is by design -> DOM Storage on the Mozilla Developer Center

(Firefox 2 permitted access to storage objects higher in the domain hierarchy than the current document. This is no longer allowed in Firefox 3, for security reasons. In addition, this proposed addition to HTML 5 has been removed from the HTML 5 specification in favor of localStorage, which is implemented in Firefox 3.5.)

Or if there is a workaround?
I wonder because offline storage that works only online sounds silly :P

If anybody wonders, the code is as easy as it gets:

function save() {  localStorage.setItem('foo','bar'); }  function load() {  var test = localStorage.getItem('foo');  alert(test); } 
like image 853
hobotron Avatar asked Sep 29 '09 14:09

hobotron


People also ask

Does localStorage work across pages?

The main features of localStorage are: Shared between all tabs and windows from the same origin. The data does not expire. It remains after the browser restart and even OS reboot.

Does localStorage expire on browser close?

localStorage is similar to sessionStorage , except that while localStorage data has no expiration time, sessionStorage data gets cleared when the page session ends — that is, when the page is closed.

Where is Firefox localStorage stored?

As of LSNG, local storage is also found in the profile directory under storage/default/ .

How long does localStorage last in browser?

LocalStorage has no expiration time, Data in the LocalStorage persist till the user manually delete it.


1 Answers

It seems a bug: Bug 507361 - localStorage doesn't work in file:/// documents
Hope is fixed soon!

2011-09-13: Bug fixed, implemented in 'Mozilla8'. I tested this with Firefox 8 and it works now.

like image 58
user183799 Avatar answered Sep 18 '22 15:09

user183799