错误:
IE
中"HTML
Parsing Error:Unable to modify the parent container element before the child
element is closed"
现象:
同事之间几个IE
测试情况下,有的报这个错,有的不报。经查询资料后,可归纳以下原因。
1.
有未关闭的
html
标签,比如
<table>
而没有
</table>
2.
在页面未加载完前
js
代码操作了
body
里的元素,将相关
js
代码移到
</body>
后面
我这里的原因是进行了某些
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 fully loaded
),文档结构仍在
loading
和
interactive
状态之间,于是,便会得到上述错误
解决办法:
要解决这个问题,可以进行
document.readyState
状态判断,当它为
complete
时再进行相应的操作
if (document.readyState=="complete")
{
createDiv ();
}
else
{
document.onreadystatechange = function(){
if (document.readyState == "complete")
{
createDiv ();
}
}
}
function createDiv()
{
var oDiv = document.createElement("DIV");
oDiv.innerHTML = 'test odiv test odiv';
document.body.appendChild(oDiv);
}
onreadystatechange
:
存储函数(或函数名),每当 readyState
属性改变时,就会调用该函数。
readyState:
存有 XMLHttpRequest
的状态。从 0
到 4
发生变化。
-
0:
请求未初始化
-
1:
服务器连接已建立
-
2:
请求已接收
-
3:
请求处理中
-
4:
请求已完成,且响应已就绪
0 - UNINITIALIZED
:
XML
对象被产生,但没有任何文件被加载。
1 - LOADING
:加载程序进行中,但文件尚未开始解析。
2 - LOADED
:部分的文件已经加载且进行解析,但对象模型尚未生效。
3 - INTERACTIVE
:仅对已加载的部分文件有效,在此情况下,对象模型是有效但只读的。
4 - COMPLETED
:文件已完全加载,代表加载成功。
分享到:
相关推荐
网页错误详细信息 用户代理: Mozilla/4.0 (compatible...消息: HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)行: 0字符: 0代码: 0 今天调试一段J
vue樱花漫天效果对应文件
Parsing, also referred to as syntax analysis, has been and continues to be an essential part of computer science and linguistics. Parsing techniques have grown considerably in importance, both in ...
Parsing Techniques:A Practical Guide 英文版 (PDF文件) 解析(语法分析)是计算机科学应用最广泛的分支之一,解析器在编译,数据库接口,自述数据,人工智能等方面有极广阔的应用,还有语言学(文本分析,...
Python_field_calculator 针对ArcGis10中字段计算器只支持Python语言的情况,现在特别上传Python版的资料,希望对大家有帮助!
这包括: 配置和规则配置和规则(不建议使用) 配置配置目录 Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser. TSLint的自定义规则tinkoff-angular-member-ordering tinkoff-...
SVN各种错误提示产生原因及处理方法大全
Knockout是一个轻量级的UI类库,通过应用MVVM模式使JavaScript前端UI简单化。
郁闷啊,有时候不得不承认,无论是什么事,曾经是好的,到后边未必还是好的,不要拿曾经的种种来判断今天的结果, 前景:之前本地用jeecg(1.7版本)设计流程、发布流程、修改流程,所有的操作都是项目有汉字启动的,...
带书签
在 'linevals' 中返回一个结构,其中包含行号和可能缺少终端分号的候选行的冒犯字符串。 以通常不会在命令行产生输出的关键字(例如,'if'、'return'、'continue' 等)开头的行将被跳过。 TARGETFILES:输入可以是...
2020-02-19 10:34:46.901 INFO 5920 --- [nio-8080-exec-1] o.apache.coyote.http11.Http11Processor : Error parsing HTTP request header Note: further occurrences of HTTP header parsing errors will be ...
infinite loop (due to an error in ListScanEx in the method FlexUtils). - FIX: The value of some string flex-properties that began with a parenthese or curly bracket had no apostrophe at the end; ...
http://en.wikipedia.org/wiki/Parsing 这个页面上的链接下载的。
yum.conf 配置yum可能有点麻烦,安装mysql时可能需要一些依赖包,所以可以在etc/yum.conf 替换该文件,然后可以使用yum search glibc yum -y install 包名 安装需要的依赖包
用于Foobar2000,基本任何版本都可以使用。可以通过选择音乐来自动生成Cue文件
Parsing JSON in Swift will teach you to harness the power of Swift and give you confidence that your app can gracefully handle any JSON that comes its way. You'll learn: - How to use ...
var i={NETWORK_ERROR:"networkError",MEDIA_ERROR:"mediaError",MUX_ERROR:"muxError",OTHER_ERROR:"otherError"},a={MANIFEST_LOAD_ERROR:"manifestLoadError",MANIFEST_LOAD_TIMEOUT:"manifestLoadTimeOut",...
Learn web scraping and crawling techniques to access unlimited data from any web source in any format. With this practical guide, you’ll learn how to use Python scripts and web APIs to gather and ...
You’ll see how regexes are used for searching, parsing, and validation: in particular the grammar extension makes them uniquely suitable for parsing, the main focus of this book. Written by Perl 6 ...