我正在处理一个客户端问题,Modernizr 意外未检测到localStorage
Internet Explorer 9 中的对象支持。我的页面正确使用 HTML 5 doctype ( <!DOCTYPE html>
) 并且开发人员工具报告该页面的浏览器模式为 IE9 和文档IE9 标准的模式,所以我希望这可以工作。
我已经在 Modernizr 中调试了以下try
/catch
块,发现一旦localStorage
访问对象就会引发 JavaScript 错误。
tests['localstorage'] = function() {
try {
localStorage.setItem(mod, mod);
localStorage.removeItem(mod);
return true;
} catch(e) {
return false;
}
};
在某些机器上,JavaScript 错误的消息是The system cannot find the file specified.
. 在其他情况下,它只是Invalid argument.
和 Internet Explorer 在引发错误之前阻塞了整整 5 分钟。
是什么导致访问localStorage
对象在 Internet Explorer 上引发错误?