本帖最后由 nongfusq 于 2011-01-27 19:33:33 编辑

解决方案 »

  1.   

    搞一个类似代理的函数调用目标函数,在代理函数中捕获。
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script>
    function Test() {
    setTimeout(proxyTarget,3)

    function proxyTarget(){
    try{
    target();
    }catch(e){
    alert("异常"+e);
    }
    }
    function tagert(){
    throw "xxx"
    }</script>
    </head>
    <body>
    <input type="button" value="start" onclick="Test()" />
    </body>
    </html>
      

  2.   

    直接在匿名函数里catch不就行了?
      

  3.   

    window.onerror=function(ex){
     alert(ex);
    }