[英]using "localStorage.setItem" Internet explorer
I want to use localStorage.setItem
in internet Explorer 11,我想在 Internet Explorer 11 中使用
localStorage.setItem
,
I tried like:我试过:
<script>
localStorage.setItem("lastname", "Smith");
</script>
but in IE console I see:但在 IE 控制台中我看到:
SCRIPT5007: Unable to get property 'setItem' of undefined or null reference.
SCRIPT5007:无法获取未定义或空引用的属性“setItem”。
I also tried the given answer like:我也试过给定的答案,如:
<script>
!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...");
}
</script>
but then I get:但后来我得到:
localstorage
can't work with file://
protocal, you need to run the page through http protocal. localstorage
不能使用file://
协议,你需要通过 http 协议运行页面。localstorage
in old version of IE 11 in win7/win8, please make sure you have installed the latest update. localstorage
可能有问题,请确保你已经安装了最新的更新。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.