Internet Explorer cannot open the Internet site error in IE6

Source: Internet
Author: User

The specific situation is as follows:
When the page is not fully loaded, a script event that generates IFRAME is triggered by clicking the mouse.
First, we thought about adding a script event to the trigger position after the page is fully loaded. In this way, no script event exists here before the page is fully loaded, naturally, no error is reported.
The above method is somewhat passive, so see the script for generating IFRAME.
The normal page structure is CopyCode The Code is as follows: <body>
<Form>
........
</Form>
</Body>

The script for generating IFRAME is:Copy codeThe Code is as follows: function createiframe (){
VaR objbody = Document. getelementsbytagname ("body"). Item (0 );
VaR objiframe = Document. createelement ("iframe ");
Objbody. appendchild (objiframe );
}

Appendchild () method to add a new subnode at the end of the node's subnode list. Therefore, the DOM after the IFRAME is created is:Copy codeThe Code is as follows: <body>
<Form>
........
</Form>
<IFRAME>
........
</Iframe>
</Body>

<IFRAME> is created when <form> has not been fully loaded. Therefore, a page error occurs in IE6.
I believe that the solution has been found here: if you create <IFRAME> before <form>, there will be no problem!
Then, we need to use another method for adding elements, insertbefore ():Copy codeThe Code is as follows: function createiframe (){
VaR objbody = Document. getelementsbytagname ("body"). Item (0 );
VaR objiframe = Document. createelement ("iframe ");
Objbody. insertbefore (objiframe, document. getelementbyid ("form1"); // form1 is the form ID
}

The insertbefore () method inserts a new node at any position in the node's subnode list.
Insertbefore has two parameters that can be set. The first parameter is the same as appendchild, and the second parameter can be null. The effect is equivalent to the insertbefore () method, you can also insert a new subnode before the specified subnode.Copy codeThe Code is as follows: <body>
<IFRAME>
........
</Iframe>
<Form ID "form1">
........
</Form>
</Body>

Related Article

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.