PageRenderTime 20ms CodeModel.GetById 10ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/content/wiki/html-parsing-error-unable-to-modify-the-parent-container-element-before-the-child-element-is-closed-kb927917.md

https://github.com/ilife5/javascript-exception-archives
Markdown | 60 lines | 37 code | 23 blank | 0 comment | 0 complexity | 5adcd70206d5547d021377db1abaf2cd MD5 | raw file
 1
 2# HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
 3
 4----
 5
 6| Language | Message                                                                                                         |
 7|----------|-----------------------------------------------------------------------------------------------------------------|
 8| 英文     | HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917) |
 9
10常见于 IE8 浏览器,不当的 DOM 操作,会导致这种异常。
11
12解决方法(以下之一):
13
14* 将需要需要 DOM 操作的部分放到 dom ready 之后执行。
15* 确保被操作的 DOM 已经渲染完成。
16* 为浏览器安装 [KB2416400](http://www.microsoft.com/zh-cn/download/search.aspx?q=KB2416400&p=2&r=10&t=28&s=Relevancy~Descending) 补丁。
17
18
19## 案例
20
21### 现象:
22
23### 异常描述:
24
25当用户访问带有应用侧边栏的页面时,就有几率报 Unable to modify the parent
26container element before the child element is closed 的错误,并导致页面渲染失败。
27
28### 原因分析:
29
30其一,3月28日上线的新代码中为了尽早执行侧边栏的相关代码,
31没有把代码放在 domReady 之后运行。即代码的执行时机可能是页面正在渲染的时候。
32
33其二,侧边栏代码执行时,如果页面元素的标签尚未正确闭合(即正在渲染的一个中间状态),
34此时如果对未闭合的元素的父元素进行了操作(插入,删除,移动),就会报上述的错误。
35
36经过排查,侧边栏的代码中,对应用中分页切换操作(switchable组件)过程中,
37有一个预期之外的操作,这个操作往 body 里插入了一个 div 元素,最终导致了报错。
38
39[演示](http://arale.alipay.im/alipay/appaside/examples/ie8-parse-error.html)
40
41### 解决方法:
42
43指定 switchable 的 element 参数(已闭合),避免被默认插入到 body 中
44(body 未渲染完成的可能性比较大)。
45
46详细故障可以参考 [支付宝故障单](http://itil.alipay.net/bug/bug_manage.htm?bugNo=BUG20130418482103&incidentNo=INC20130415175808597&action=view)。
47
48## 相关异常
49
50
51## 参考
52
53* [Internet Explorer 无法打开 Internet 站点 XXX 操作已中止。(KB927917)](http://support.microsoft.com/KB/927917)
54* [JS error in IE8 (HTML Parsing Error)](http://www.longtailvideo.com/support/forums/jw-player/setup-issues-and-embedding/10476/js-error-in-ie8-html-parsing-error)
55* [Problem with HTML Parser in IE](http://stackoverflow.com/questions/301484/problem-with-html-parser-in-ie)
56* [HTML Parsing Error--Unable to modify the parent container element before the child element is closed (KB927917)](http://answers.microsoft.com/en-us/ie/forum/ie9-windows_7/html-parsing-error-unable-to-modify-the-parent/968ddb1a-2e72-e011-8dfc-68b599b31bf5)
57* [HTML Parsing Error: Unable to modify the parent element before the child element is closed (K927917) in eBay -- eBay problem or mine?](http://answers.microsoft.com/en-us/ie/forum/ie8-windows_vista/html-parsing-error-unable-to-modify-the-parent/932e9ebc-3168-4a5e-b65c-3407ad9b9bbf)
58* [HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)](http://answers.microsoft.com/en-us/ie/forum/ie8-windows_other/html-parsing-error-unable-to-modify-the-parent/e64759e0-d344-42d6-b1d8-0ce27504dd71)
59* [I am new to IE8 and have received this error continuously since downloading IE8](http://answers.microsoft.com/en-us/ie/forum/ie8-windows_other/i-am-new-to-ie8-and-have-received-this-error/a6e6a3be-6f1f-41a9-9ede-d4d878664615)
60* [Unable to modify the parent container element before the child element is closed](http://forums.techarena.in/software-development/1254863.htm)