Internet Explorer cannot open the Internet site error _javascript technique under IE6

Source: Internet
Author: User
The specific situation is this:
When the page is not fully loaded, mouse clicks trigger a script event that generates an IFRAME.
First of all, the script event, after the page loaded completely, and then dynamically added to the trigger location, so that the page loaded completely before, here is not a script event, Nature will not complain.
The above approach is somewhat passive, so see the script that generates the IFRAME.
The normal page structure is
Copy Code code as follows:

<body>
<form>
........
</form>
</body>

The script that generates the IFRAME is:
Copy Code code 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 child node at the end of the node's child node list. So the DOM after the IFRAME is created is:
Copy Code code as follows:

<body>
<form>
........
</form>
<iframe>
........
</iframe>
</body>

The &LT;IFRAME&GT is created because the <form> is not loaded completely, so there is a page error under IE6.
Believe that when you see here, the solution has been found: the <iframe> created in <form> before, there will be no problem!
So, we need to use another method of adding elements insertbefore ():
Copy Code code 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 ID of the form
}

InsertBefore () method to insert a new node anywhere in the node's child node list.
InsertBefore has 2 parameters to set, the first is the same as AppendChild, the second can be null, the effect is equal to the InsertBefore () method, or you can insert a new child node before which child node you want to specify.
Copy Code code 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.