adolfjap

js 捕获全局错误 exception

window.onerror = handleError

function handleError(msg,url,l) { 

  var txt="There was an error on this page.\n" ; 

  txt+="Error: " + msg + "\n" ;

  txt+="URL: " + url + "\n" ;

  txt+="Line: " + l + "\n" ;

  txt+="Click OK to continue.\n\n"  ;   

      alert(txt);     

     return true;

}

评论