IE8 下的Js错误HTML Parsing Error...
作者:bea
网页错误详细信息
用户代理: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; QQDownload 551; SLCC2; .NET CLR 2.0.50727)
时间戳: Wed, 12 Aug 2009 07:02:03 UTC
消息: HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
行: 0
字符: 0
代码: 0
今天调试一段JS代码出现这个状况..在火狐 IE7 和IE6下都正常...郁闷,在网上搜索了一下相关资料 一般错误都是指所指定的标签没有加载完就是用该对象....
检查了代码 从表面上看没有什么问题
如下
<body>
<script language="javascript">
var bgObj = document.createElement("div");
bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:101;";
document.body.appendChild(bgObj);
</script>
</body>
其实 仔细检查出来就发现 这段代码会在body没有加载完毕之前运行....
问题就出在这里....
所以 代码只能放在波电压外面去执行
<body>
</body>
<script language="javascript">
var bgObj = document.createElement("div");
bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:101;";
document.body.appendChild(bgObj);
</script>
这样OK没问题了...看来IE 的逻辑性越来越强了.....可能以前很多代码都会出现这种问题咯
猜你喜欢
您可能感兴趣的文章:
- 精通Javascript+jQuery 视频教程 在线观看
- JQUERY 浏览器判断实现函数
- google地图的路线实现代码
- JavaScript 字符串乘法
- javascript 短路法代码精简
- 斜45度寻路实现函数
- javascript 多级checkbox选择效果
- 调用js时ie6和ie7,ff的区别
- jquery 入门教程 [翻译] 推荐
- jQuery select控制插件
- javascript 无提示关闭窗口脚本
- javascript addBookmark 加入收藏 多浏览器兼容
- 用JavaScript将从数据库中读取出来的日期型格式化为想要的类型。
- javascript 客户端验证上传图片的大小(兼容IE和火狐)
- js中的window.open返回object的错误的解决方法
- JavaScript 提升运行速度之循环篇 译文
- jQuery ui 1.7更新小结
- 获取 textarea 标签第n行的文字的js代码
- css+js完美控制图片大小