开发者

LocalStorage Firefox 3.6

开发者 https://www.devze.com 2023-01-18 21:15 出处:网络
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?

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).


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消