Skip navigation.

crocodile's blog

a python lover

body.appendChild 已终止操作

document.body.appendChild() 会导致站点无法正常加载。

出现提示:Internet Explorer无法打开Internet站点 ×××?? 已终止操作。



通常这种问题只在IE中出现。而在firefox中却不会,因为Firefox的body在body标签没有被浏览器完全读入之前就存在;而IE的body则必须在body标签被浏览器完全读入之后才存在.

解决办法:

1、在一个已加载的对象上调用appendChild(),来创建对象。

2、页面加载完毕后,再执行document.body.appendChild()动作,可以把它放到</body>后面。

3、用window.setTimeout(),来延时对document.body.appendChild()的调用。

我们重点来讨论第二种解决办法。
要让页面加载完后,在执行动作,可以在</body>用js绑定document.body.onload方法,但是在firefox下document.body.onload是undefined,因此在firefox下是可以用window.onload来代替
<script type="text/javascript">
function init(arg){
        //do sth.
}
if(typeof(document.body.onload)=="undefined")
        window.onload=goto_page(arg);
else
        document.body.onload=new Function('goto_page(arg);');
</script>



vim中文手册关于>&2、2>&1等重定向的详细解释

Comments

Anonymous 13. July 2008, 08:50

Anonymous writes:

正遇到這個問題..謝謝你的分享, 幫我解決了這個問題!

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies

December 2009
S M T W T F S
November 2009January 2010
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31