Skip to content

Instantly share code, notes, and snippets.

@ksk1015
Created July 28, 2017 08:34
Show Gist options
  • Save ksk1015/e9fb25db97097e3b14746559b95c4243 to your computer and use it in GitHub Desktop.
Save ksk1015/e9fb25db97097e3b14746559b95c4243 to your computer and use it in GitHub Desktop.
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;
}
}
@ksk1015
Copy link
Author

ksk1015 commented Jul 28, 2017

Safari private browseだとsessionStorage, localStorageのプロパティは存在しても、setItemでエラーになるので、それを考慮した判定。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment