Created
March 13, 2018 06:07
-
-
Save liuwenzhuang/bec033abe131034a002367b2b979c7df to your computer and use it in GitHub Desktop.
localStorage在无痕模式下存在,但调用其方法会抛异常; localStorage is exist in incognito mode, but invoking functions of localStorage will throw exceptions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 是否支持localStorage | |
*/ | |
function isSupportStorage() { | |
if(!localStorage) return false; | |
try { | |
localStorage.setItem('__test__', '__test__'); | |
localStorage.removeItem('__test__'); | |
return true; | |
} catch(e) { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment