- [请在IE 11中选中此选项,如果禁用此选项,则存储对象将在IE中未定义:
- 单击“工具”菜单,然后选择“ Internet选项”。
我想在Internet Explorer 11中使用localStorage.setItem
,>
我尝试过:
<script> localStorage.setItem("lastname", "Smith"); </script>
但是在IE控制台中,我看到:
SCRIPT5007:无法获取未定义或空引用的属性'setItem'。
我也尝试过given answer:
<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>
但后来我得到:
我想在Internet Explorer 11中使用localStorage.setItem,我尝试过:
localstorage
不能与file://
协议一起使用,您需要通过http协议来运行页面。localstorage
,请确保已安装最新更新。