Html IE6中未定义的webshim polyfill本地存储
当我在IETester IE6窗口中运行以下代码时:Html IE6中未定义的webshim polyfill本地存储,html,local-storage,webshim,Html,Local Storage,Webshim,当我在IETester IE6窗口中运行以下代码时: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DealingTree</title> <meta http-equiv="Content-type" content="text/html;charset=utf-8"/>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>DealingTree</title>
<meta http-equiv="Content-type" content="text/html;charset=utf-8"/>
<script type="text/javascript" src="/js/modernizr.js"> </script>
<script type="text/javascript" src="/js/jquery.js"> </script>
<script type="text/javascript" src="/js/sssl.js"> </script>
<script type="text/javascript" src="/js/webshims/js-webshim/minified/polyfiller.js"> </script>
</head>
<body>
<script type="text/javascript">
//<![CDATA[
$.webshims.polyfill('json-storage');
localStorage.setItem('myKey','myValue');
alert(localStorage.getItem('myKey'));
//]>
</script>
</body>
</html>
该代码在IE7模式下运行的IE9中运行良好
当我改用道格拉斯·克罗克福德和雷米·夏普的——据推测这是基于他们的——我没有这个问题
请帮助?IE6根本不支持HTML5功能。这对于一个本应已死的古老浏览器来说并不奇怪(IE6是在2001年发布的,HTML5的基础是在2004年才奠定的)。有关更多详细信息,请参阅
请注意,有些包装器能够模拟此类功能,例如建议与IE6+兼容。我收到一封来自作者(Alexander Farkas)的电子邮件,解释使用polyfill的代码必须在domready事件处理程序中,例如:
$.webshims.polyfill('json-storage');
$(function(){
localStorage.setItem('myKey','myValue');
alert(localStorage.getItem('myKey'));
});
有关更多信息:
我知道这一点。webshim polyfill旨在为IE6和其他非支持浏览器提供一个后备版本。@Andrew M.Andrews III:太好了。您还知道哪些其他相关信息,但问题中遗漏了这些信息?(读者应该凭空推断,因为当然每个人都知道这个兼容性垫片。)看,这类问题将整个问题从“为什么IE6不支持localStorage?”改为“为什么localStorage垫片不工作?”——这是一个完全不同的问题。很抱歉,我认为标题传达了问题出在webshim polyfill上。这是Webshims polyfill主页:加载所有webshim时,它运行正常吗
$.webshims.polyfill()
(我知道这不会有什么区别)我只是想确定一下;不幸的是,问题仍然存在。
$.webshims.polyfill('json-storage');
$(function(){
localStorage.setItem('myKey','myValue');
alert(localStorage.getItem('myKey'));
});