提交 9274840c 编写于 作者: C codeKonami

adding a test to verify the localStorage is supported fixing a bug on private browsing on safari

上级 f943d2a7
...@@ -18,9 +18,21 @@ window.fakeStorage = { ...@@ -18,9 +18,21 @@ window.fakeStorage = {
} }
}; };
function LocalScoreManager() { function isLocalStorageNameSupported()
var localSupported = !!window.localStorage; {
var testKey = 'test', storage = window.localStorage;
try {
storage.setItem(testKey, '1');
storage.removeItem(testKey);
return true;
}
catch (error) {
return false;
}
}
function LocalScoreManager() {
var localSupported = isLocalStorageNameSupported();
this.key = "bestScore"; this.key = "bestScore";
this.storage = localSupported ? window.localStorage : window.fakeStorage; this.storage = localSupported ? window.localStorage : window.fakeStorage;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册