如何检测Windows本地存储是否可用? [英] How can I detect if Windows local storage is available?
本文介绍了如何检测Windows本地存储是否可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码:
//if (Modernizr.localstorage) {
// // window.localStorage is available!
//} else {
// // document.location.href = '/Error/Message/OldBrowser';
//}
是否有某种方式可以做同样的事情而无需使用Modernizr的开销?
Is there some way that I can do the same thing without the overhead of using Modernizr?
推荐答案
if (!!window.localStorage) {
/* you have localstorage */
}
注意:即使在IE8上,本地存储也是本地可用的
note: localstorage is natively available even on IE8
这篇关于如何检测Windows本地存储是否可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文