IE8 下的Js错误HTML Parsing Error...

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

IE8 下的Js错误HTML Parsing Error...

  2020-05-12 我要评论

网页错误详细信息

用户代理: 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 的逻辑性越来越强了.....可能以前很多代码都会出现这种问题咯

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们