PageRenderTime 38ms CodeModel.GetById 15ms 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. # HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
  2. ----
  3. | Language | Message |
  4. |----------|-----------------------------------------------------------------------------------------------------------------|
  5. | 英文 | HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917) |
  6. 常见于 IE8 浏览器不当的 DOM 操作会导致这种异常
  7. 解决方法以下之一
  8. * 将需要需要 DOM 操作的部分放到 dom ready 之后执行
  9. * 确保被操作的 DOM 已经渲染完成
  10. * 为浏览器安装 [KB2416400](http://www.microsoft.com/zh-cn/download/search.aspx?q=KB2416400&p=2&r=10&t=28&s=Relevancy~Descending) 补丁。
  11. ## 案例
  12. ### 现象
  13. ### 异常描述
  14. 当用户访问带有应用侧边栏的页面时就有几率报 Unable to modify the parent
  15. container element before the child element is closed 的错误并导致页面渲染失败
  16. ### 原因分析
  17. 其一3月28日上线的新代码中为了尽早执行侧边栏的相关代码
  18. 没有把代码放在 domReady 之后运行即代码的执行时机可能是页面正在渲染的时候
  19. 其二侧边栏代码执行时如果页面元素的标签尚未正确闭合即正在渲染的一个中间状态
  20. 此时如果对未闭合的元素的父元素进行了操作插入删除移动就会报上述的错误
  21. 经过排查侧边栏的代码中对应用中分页切换操作switchable组件过程中
  22. 有一个预期之外的操作这个操作往 body 里插入了一个 div 元素最终导致了报错
  23. [演示](http://arale.alipay.im/alipay/appaside/examples/ie8-parse-error.html)
  24. ### 解决方法
  25. 指定 switchable element 参数已闭合避免被默认插入到 body
  26. body 未渲染完成的可能性比较大
  27. 详细故障可以参考 [支付宝故障单](http://itil.alipay.net/bug/bug_manage.htm?bugNo=BUG20130418482103&incidentNo=INC20130415175808597&action=view)。
  28. ## 相关异常
  29. ## 参考
  30. * [Internet Explorer 无法打开 Internet 站点 XXX 操作已中止(KB927917)](http://support.microsoft.com/KB/927917)
  31. * [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)
  32. * [Problem with HTML Parser in IE](http://stackoverflow.com/questions/301484/problem-with-html-parser-in-ie)
  33. * [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)
  34. * [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)
  35. * [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)
  36. * [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)
  37. * [Unable to modify the parent container element before the child element is closed](http://forums.techarena.in/software-development/1254863.htm)