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

2021-04-07 06:26

阅读:428

标签:tor   tab   ret   form   within   word   when   javascrip   hub   

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:

  • message: error message (string). Available as event (sic!) in HTML onerror=""handler.
  • source: URL of the script where the error was raised (string)
  • lineno: Line number where error was raised (number)
  • colno: Column number for the line where the error occurred (number)
  • error: Error Object (object)

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.

 

 

 


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

标签:tor   tab   ret   form   within   word   when   javascrip   hub   

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


评论


亲,登录后才可以留言!