IE 8 HTML Parsing Error: Unable to modify the parent container element before the child element is c
来源:互联网 发布:郑州it外包公司 编辑:程序博客网 时间:2024/04/30 17:37
它的发生,是因为某些DOM操作发生在DOM树加载完成之前,比如appendChild
就像下面的代码:
<html>
<head>
</head>
<body>
<div>
<script type="text/javascript">
alert(document.readyState);
var oDiv = document.createElement("DIV");
oDiv.innerHTML = 'test odiv test odiv';
document.body.appendChild(oDiv);
</script>
</div>
</body>
</html>
当解析到DIV时就开始在BODY上appendChild,而这个时候BODY是还没有完全就绪的(It is not fullyloaded),文档结构仍在loading和interactive状态之间,于是,便会得到上述错误。当然,该错误目前已确切知道的会存在于IE6和IE7两个版本中(低于IE6的未进行测试),在IE8中将会得到一个HTML解析错误:HTML Parsing Error: Unable tomodify the parent container element before the child element is closed(KB927917)
1.要解决这个问题,可以进行document.readyState状态判断,当它为complete时再进行相应的操作,或者给script标签加上defer属性(该属性在IE8中已不获支持)。
2.或者
js中加入了 setTimeout("XXXX()",1000);,使其获得足够的加载时间后执行目标(XXXX)的function,于是问题得到解决
说 明
这个属性是只读的,传回值有以下的可能:
0-UNINITIALIZED:XML 对象被产生,但没有任何文件被加载。
1-LOADING:加载程序进行中,但文件尚未开始解析。
2-LOADED:部分的文件已经加载且进行解析,但对象模型尚未生效。
3-INTERACTIVE:仅对已加载的部分文件有效,在此情况下,对象模型是有效但只读的。
4-COMPLETED:文件已完全加载,代表加载成功。
范 例
alert("The readyState property is " + xmlDoc.readyState);
if (document.readyState=="complete")
{
AdjustImageSize();
}
else
{
document.onreadystatechange = function()
{
if (document.readyState == "complete")
{
AdjustImageSize();
}
}
}
function AdjustImageSize()
{
var imageWidth = document.all["SendPic"].width;
var imageHeight = document.all["SendPic"].height;
if (imageWidth == 0 && imageHeight == 0)
{
document.write ("图片下载失败,请刷新!");
return;
}
if (imageWidth > 160 || imageHeight > 160)
{
if (imageWidth > imageHeight)
{
k = 160 / imageWidth;
imageHeight = imageHeight * k;
imageWidth = 160;
}
else
{
k = 160 / imageHeight;
imageWidth = imageWidth * k;
imageHeight = 160;
}
document.all["ImgResized"].value = "1";
}
document.all["SendPic"].width = imageWidth;
document.all["SendPic"].height = imageHeight;
document.all["ImgWidth"].value = imageWidth;
document.all["ImgHeight"].value = imageHeight;
}
</script>
function showMessage() {
if (document.readyState == "complete")
{
art.dialog.alert('Yeah~~,This is BackGround Dialog!');
}
}
- IE 8 HTML Parsing Error: Unable to modify the parent container element before the child element is c
- IE 8 HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
- IE 8 HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
- IE 8 HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
- IE 8 HTML Parsing Error:Unable to modify the parent container element before the child element is cl
- IE 8 HTML Parsing Error:Unable to modify the parent container element before the child element is cl
- HTML Parsing Error: Unable to modify the parent container element before the child element is closed
- HTML Parsing Error:Unable to modify the parent container element before the child element is closed
- HTML Parsing Error: Unable to modify the parent container element before the child element is closed
- IE8 中"HTML Parsing Error:Unable to modify the parent container element before the child element is c
- IE8 中"HTML Parsing Error:Unable to modify the parent container element before the child element is c
- IE8 中"HTML Parsing Error:Unable to modify the parent container element before the child element is c
- IE8 中"HTML Parsing Error:Unable to modify the parent container element before the child element is c
- HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
- badboy进行录制时,提示错误HTML Parsing Error: Unable to modify the parent container element before the child e
- BUG笔记:Win XP IE8下HTML Parsing Error: Unable to modify the parent container element before the child
- BUG笔记:Win XP IE8下HTML Parsing Error: Unable to modify the parent container element before the child
- javascript错误解决:Unable to modify the parent container element before the child element is closed
- UVa OJ全部题目列表(按难度分级,仅标题)
- 【学习笔记】log4cxx配置详解
- Exception初识
- 【转】关于Invalidate、InvalidateRect和UpdateWindow
- eclipse连接oracle数据库的方法
- IE 8 HTML Parsing Error: Unable to modify the parent container element before the child element is c
- libxml/tree.h not found(xcode4.5解决方案)
- “3D打印”的魔法时代还有多远?
- 更改MFC生成的程序的默认exe图标
- SCWCD(Servlet&Jsp learning)第三问-------JSP内置对象详解
- Android Animation
- 递归三兄弟——数的乘方、背包问题、组合的Java实现
- 三维空间中的旋转--旋转向量
- android4.0.3在pandaboard上的成功移植