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

Viewed 15176

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);
}
3 Answers

As of Oct 5 2020, localStorage on Firefox seems to be broken again. Try this:

  1. Download Mozilla demo page: https://mdn.github.io/dom-examples/web-storage/
  2. Change the animal/color to something other than default.
  3. close the page's tab (or the browser).
  4. Download the page again. It's back to defaults. (Firefox 81:0 et.al.)

Even worse, if you do step 1 & 2 above and then open another copy of the demo in a new tab, not only does the new tab not get the saved data, but the original demo page (refresh it) has gone back to the defaults; as though the new tab STEPPED on the saved data.

Related