window.onerror事件用来自定义错误处理

时间:2018-05-31 14:09:34   收藏:0   阅读:445

Event reference:      https://developer.mozilla.org/en-US/docs/Web/Events

 http://w3c.github.io/html/webappapis.html#events

 

技术分享图片

技术分享图片

技术分享图片

原文: https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror

An event handler for the error event. Error events are fired at various targets for different kinds of errors:

Installing a global error event handler is useful for automated collection of error reports.

Syntax

For historical reasons, different arguments are passed to window.onerror and element.onerror handlers (as well as on error-type window.addEventListenerhandlers).

window.onerror

window.onerror = function(message, source, lineno, colno, error) { ... }

Function parameters:

When the function returns true, this prevents the firing of the default event handler.

window.addEventListener(‘error‘)

window.addEventListener(‘error‘, function(event) { ... })

event of type ErrorEvent contains all the information about the event and the error.

 

 

 

原文:https://www.cnblogs.com/oxspirt/p/9116318.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!