3

According to everything I've read, Firefox 3.5+ supports localStorage. And yet I'm seeing the alert (failing) in Firefox 3.6. Do I have some strange settings in my Firefox? Any ideas?

function supports_html5_storage() {
    try {
        return 'localStorage' in window && window['localStorage'] !== null;
    } catch (e) {
        alert('failing');
        return false;
    }
}

Note: The page has an HTML5 doctype (though I think this makes no difference).

4
  • 1
    Your code works fine for me. You should include the value of "e" in your alert, of course.
    – Pointy
    Commented Oct 1, 2010 at 14:15
  • So it's some strange setting in my version of Firefox? I suppose that's alright, then. I'll try adding e.
    – TRiG
    Commented Oct 1, 2010 at 14:20
  • e is [Exception... "Security error" code: "1000" nsresult: "0x805303e8 (NS_ERROR_DOM_SECURITY_ERR)" location: "http://[domain name elided]/public/javascripts/switch_style.js Line: 18"]
    – TRiG
    Commented Oct 1, 2010 at 14:22
  • A bit of googling on the error number fixed it. In about:config I had dom.storage.enabled set to false. I don't recall doing that. It may be something to do with NoScript (though javascript was enabled).
    – TRiG
    Commented Oct 1, 2010 at 14:27

2 Answers 2

6

Even though Firefox supports localStorage, it can be turned off. Check that it is turned on.

Go to about:config and check that dom.storage.enabled is set to true.

0

I just ran into the bug described at http://meyerweb.com/eric/thoughts/2012/04/25/firefox-failing-localstorage/: Firefox disallows local storage if you have your cookie options set to "Ask every time". Strange but true, at least in FF12 that I was using at the time. Workaround is to set your cookies to keep for session or until they expire.

Not the answer you're looking for? Browse other questions tagged or ask your own question.