IE8 "HTML parsing error:unable to modify the parent container element before the child element is closed" error

Source: Internet
Author: User

First, IE8 report the following error, Solution:
Page Error Details
Message: HTML parsing error:unable To modify the parent container element before the child element is closed (KB927917)
Line: 0
Character: 0
Code: 0
1. See if there are HTML tags that are not closed, such as <table> without </table>
2, whether the page is not loaded before the JS code operation of the BODY element, the relevant JS code moved to </body> behind
3, whether to add a addthis in the code to share JS
4, whether IE8 open the compatibility view
(My page error is caused by 3 or 42 reasons)


Second, this error occurs because some DOM operations occur before the DOM tree is loaded, such as AppendChild
, like the following code:
</ Head>
<body>
<div>
<script type= "Text/javascript";
    alert ( Document.readystate);
    var odiv = document.createelement ("DIV");
    odiv.innerhtml = ' afish.cnblogs.com ';
    Document.body.appendChild (odiv);
</script>
</div>
</body>
When the div is parsed, it begins to appendchild on the body, And this time the body is still not fully ready (It is not fully loaded), the document structure is still between the loading and interactive state, so you will get the above error. Of course, the error is now known to exist in IE6 and IE7 two versions (not tested below IE6), in IE8 will get an HTML parsing error: HTML parsing error:unable to modify the parent container element before the child element is closed (KB927917)
1. To solve this problem, The document.readystate state can be judged when it is complete and then the corresponding action is taken, or the script tag is added with the defer attribute (this property is not supported in IE8).
2. Or add setTimeout ("xxx ()", 1000) to JS, so that it gets enough load time to execute the function of the target (XXX), then the problem is resolved.

IE8 "HTML parsing error:unable to modify the parent container element before the child element is closed" error

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.