本帖最后由 yifulou 于 2009-11-17 00:42:26 编辑

解决方案 »

  1.   

    http://blog.csdn.net/xiaofan_sap/archive/2009/10/15/4677394.aspx
      

  2.   

    一看见特权 还是which就知道是 精通javascript书者谁知道怎么让IE无论如何都不出现左下角的黄叹号啊?(不改浏览器设置的情况下)<script type="text/javascript">
    <!--
    window.onerror = function(){
    alert('测试捕获')
    return true;
    }
    var s = function(){
    aaalert('error'); // 这是错误
    }
    s();
    //-->
    </script>
      

  3.   


    <script type="text/javascript">
    //添加Function原型方法
    Function.prototype.trythis = function(){
    var args = Array.prototype.slice.call(arguments,0);
    try{this.apply(null,args);}catch(e){}
    };//任何函数
    var hi = function(str){
    alert(str);
    alert(x);
    };//必要的时候调用该方法进行try
    hi.trythis('this will be fine!');//不需要的时候直接调用
    hi('you will see an error!');
    </script>
    当然,如果不想污染函数原型对象,可以将trythis函数独立出来作为一个单独运行的函数也可以。