JavaScript global event mechanism

前端 未结 10 2089
无人及你
无人及你 2020-11-22 14:39

I would like to catch every undefined function error thrown. Is there a global error handling facility in JavaScript? The use case is catching function calls from flash that

10条回答
  •  长发绾君心
    2020-11-22 15:16

    // display error messages for a page, but never more than 3 errors
    window.onerror = function(msg, url, line) {
    if (onerror.num++ < onerror.max) {
    alert("ERROR: " + msg + "\n" + url + ":" + line);
    return true;
    }
    }
    onerror.max = 3;
    onerror.num = 0;
    

提交回复
热议问题