If i were to test for localStorage
in the users browser with JavaScript, eg
var hasStorage = (function() {
try {
localStorage.setItem(mod, mod);
localStorage.removeItem(mod);
return true;
} catch (exception) {
return false;
}
}());
if (hasStorage) {
// store things in places
}
(from: https://mathiasbynens.be/notes/localstorage-pattern )
Can I infer (without explicit checks) that if hasStorage === true
, then sessionStorage
is also available, or is it possible to have one disabled with the other enabled?
localStorage
does not appear to be related to sessionStorage
at chromium. It is possible to launch chromium with --disable-local-storage
flag which logs error when trying to set localStorage
Uncaught TypeError: Cannot read property 'setItem' of null
though there does not appear to be an official flag to disable sessionStorage
at chromium List of Chromium Command Line Switches . Note, chrome is built using chromium source code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.