When the page does not have ready, the appendchild or innerhtml operation of htmlobject is called. In this case, a dialog box is displayed on IE: "Internet Explorer cannot open the site, and the operation has been terminated"
The solution is as follows:
(1) Determine document. readystate = "complete" in the appendchild or innerhtml operation. If it is not, setTimeout several seconds and then perform this operation again. However, this attribute is only valid for IE and opeara. The document of FF does not have the readystate attribute and is always undefined.
(2) Use the defer attribute in the script. It is intended to execute the script after the page is loaded, so that the object cannot be found. Defer does not consider whether all external files have been downloaded, but determines whether the current page has been fully loaded. In additionCodeThe document. Write method cannot be written in the block.
Method 2: When loading external files, the effect is not good and may cause other unexpected problems.
So the second method is used, and the recursive method is used.
Function mytest (){
If (document. readystate = "complete ")
// Execute the Function
Else
SetTimeout ("mytest ()", 1000 );
}