ErrorEvent

ErrorEvent 事件对象在脚本发生错误时产生,它可以提供发生错误的脚本文件的文件名,以及发生错误时所在的行号等信息。

属性

除了从 Event 接口继承来的属性外,还有下面这些自身属性。

ErrorEvent.prototype.message 只读
一个字符串,包含了所发生错误的描述信息。
ErrorEvent.prototype.filename 只读
一个 字符串,包含了发生错误的脚本文件的文件名。
ErrorEvent.prototype.lineno 只读
一个数字,包含了错误发生时所在的行号。
ErrorEvent.prototype.colno 只读
一个数字,包含了错误发生时所在的列号。
ErrorEvent.prototype.error 只读
发生错误时所抛出的 Error 对象。

构造函数

ErrorEvent()
根据传入的参数构造 ErrorEvent 实例。

方法

除了从 Event 接口继承来的方法外,没有其他方法。

规范

规范名称 规范状态 备注
HTML Living Standard
ErrorEvent
Living Standard 增加了 error 属性以及其构造函数的第五个参数
HTML5
ErrorEvent
Recommendation 最初规范

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
ErrorEventChrome Full support 10Edge Full support YesFirefox Full support YesIE Full support YesOpera Full support 11Safari Full support YesWebView Android Full support YesChrome Android Full support 18Firefox Android Full support YesOpera Android Full support 11Safari iOS Full support YesSamsung Internet Android ?
ErrorEvent() constructorChrome Full support YesEdge ? Firefox ? IE ? Opera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android ? Opera Android Full support YesSafari iOS ? Samsung Internet Android ?
colnoChrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?
error
Experimental
Chrome Full support YesEdge Full support 12Firefox Full support YesIE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?
filenameChrome Full support 10Edge Full support 12Firefox Full support YesIE ? Opera Full support 11Safari Full support YesWebView Android Full support YesChrome Android Full support 18Firefox Android Full support YesOpera Android Full support 11Safari iOS Full support YesSamsung Internet Android ?
linenoChrome Full support 10Edge Full support 12Firefox Full support YesIE ? Opera Full support 11Safari Full support YesWebView Android Full support YesChrome Android Full support 18Firefox Android Full support YesOpera Android Full support 11Safari iOS Full support YesSamsung Internet Android ?
messageChrome Full support 10Edge Full support 12Firefox Full support YesIE ? Opera Full support 11Safari Full support YesWebView Android Full support YesChrome Android Full support 18Firefox Android Full support YesOpera Android Full support 11Safari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.

相关链接