Document. body. appendChild () causes the site to fail to load normally. The following message is displayed: Internet Explorer cannot open the Internet site XXX ?? The operation has been terminated.
Generally, this problem only occurs in IE. But not in firefox, because Firefox's body exists before the body tag is fully read by the browser, and IE's body must exist after the body tag is fully read by the browser. in the page loading process (before the body ends: </body>), use document. body. appendChild () will generate such an error!
Solution:
1. Call appendChild () on a loaded object to create an object.
2. After the page is loaded, execute the document. body. appendChild () action to put it behind </body>.
3. Determine document in the appendChild or innerHTML operation. readyState = "complete". If not, use window. setTimeout () to delay the document. body. appendChild. However, this attribute is only valid for ie and opeara. The document of ff does not have the readyState attribute and is always undefined.
4. 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 addition, the document. write method cannot be written in a code block with a defer label.
5. An error occurs when ajax is used. Solution: Determine document. readyState = "complete" in the appendChild or innerHTML operation. If no, setTimeout will be performed several seconds later.
<script type="text/javascript"> var tar=function() { var chd=window.top.document.createElement("div"); window.top.document.body.appendChild(chd); } if(document.readyState!="complete") window.setTimeout(tar,10); else tar(); </script>
|
More detailed information: http://support.microsoft.com/kb/927917