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 <IFRAME> 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>