Mik*_*ite 28 javascript local-storage internet-explorer-9
我在我的JS应用程序中使用localStorage,我想知道为什么IE9声称localStorage == undefined
.据我所知,IE8支持它,有没有办法让它在新版本中运行?
小智 17
IE 11的工作原理
您只需要两个将文件://127.0.0.1添加到安全选项卡下的受信任区域(注意:确保未选中https复选框)将此行添加到顶部或您的脚本,具体取决于您可能没有的代码需要除非你无法连接到互联网.
!localStorage && (l = location, p = l.pathname.replace(/(^..)(:)/, "$1$$"), (l.href = l.protocol + "//127.0.0.1" + p));
Run Code Online (Sandbox Code Playgroud)
!localStorage && (l = location, p = l.pathname.replace(/(^..)(:)/, "$1$$"), (l.href = l.protocol + "//127.0.0.1" + p));
if (typeof(Storage) != "undefined") {
// Store
localStorage.setItem("lastname", "Smith");
// Retrieve
alert(localStorage.getItem("lastname"));
} else {
alert("Sorry, your browser does not support Web Storage...");
}
Run Code Online (Sandbox Code Playgroud)
尝试像这样打开文件
file://127.0.0.1/c$/pathtofile/file.html
归档时间: |
|
查看次数: |
29899 次 |
最近记录: |