test if localStorage is usable, fixes #2350

This commit is contained in:
j 2014-03-03 20:22:47 +00:00
parent 37f3ca1f47
commit 09af7fa1ac

View file

@ -117,7 +117,14 @@ Ox.localStorage = function(namespace) {
localStorage = window.localStorage || {};
// FF 3.6 can't assign to or iterate over localStorage
for (var key in localStorage) {};
// In Safari (OS X or iOS) is in private browsing mode,
// it appears as though localStorage is available,
// but trying to call .setItem throws an exception.
localStorage.setItem("OxJS.writeTest", "");
localStorage.removeItem("OxJS.writeTest");
} catch (e) {
console.log('localStorage disabled');
localStorage = {};
}
function storage(key, value) {