但是我把window.onerror="errhandle()";这一句注释掉,程序也能运行通过啊~`
 那这句不是多余了吗?

解决方案 »

  1.   

    那当程序有错误产生时,window.onerror="errhandle()"中的errhandle()函数是怎么执行的呢?
       或者说它执行的结果是什么啊?
      

  2.   

    <body>
    <img name="img1" src="http://community.csdn.net/images/csdn.gif" style="position:absolute;filter:alpha(opacity=0);">
    </body>
    <script language=javascript>
    function fade(o){
    this.obj = o;
    this.offset=5;
    this.timer = null;
    this.act   = "in";
    this.action= function(){
    //alert(this.obj.tagName);
    var curOpacity = this.obj.filters.alpha.opacity;
    if( this.act == "out" )
    {
    if(curOpacity > 0)
    {
    this.obj.filters.alpha.opacity-=this.offset;
    }
    else 
    {
    this.act = "in";
    this.obj.style.left= Math.random()*800 + "px";
    this.obj.style.top = Math.random()*600 + "px";
    }
    }
    else
    {
    if(curOpacity<100)
    {
    this.obj.filters.alpha.opacity+=this.offset;
    }
    else 
    {
    this.act = "out";
    }
    }
    };
    this.play = function(){ 
    var self=this;
    var f = function(){self.action()};
    this.timer=setInterval(f,40);
    };
    this.stop = function(){
    if(this.timer) clearInterval( this.timer );
    };
    }
    var m1 = document.images[0];
    var f1 = new fade(m1);
    f1.play();
    </script>
      

  3.   

    贴错了。
    --------------------------------那当程序有错误产生时,window.onerror="errhandle()"中的errhandle()函数是怎么执行的呢?
    或者说它执行的结果是什么啊?
    ---------------------------------
    一般来说可以在调试的时候提示一些信息,或者其它一些的处理