Created
July 28, 2017 08:34
-
-
Save ksk1015/e9fb25db97097e3b14746559b95c4243 to your computer and use it in GitHub Desktop.
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
function supportWebStorage () { | |
if (!window.sessionStorage) { | |
return false; | |
} | |
try { | |
var key = 'supportWebStorage-' + (new Date()).getTime(); | |
window.sessionStorage.setItem(key, 1); | |
window.sessionStorage.removeItem(key); | |
return true; | |
} catch(err) { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Safari private browseだとsessionStorage, localStorageのプロパティは存在しても、setItemでエラーになるので、それを考慮した判定。