概述

AbstractWorker接口的onerror特性是一个事件句柄,在 Workererror事件触发并冒泡时执行。

语法

myWorker.onerror = function() { ... };

示例

下面的代码片段展示了通过 Worker() 创建 Worker 对象的过程, 以及设置onerror回调函数:

var myWorker = new Worker("worker.js");

myWorker.onerror = function() {
  console.log('There is an error with your worker!');
}

规范

Specification Status Comment
HTML Living Standard
AbstractWorker.onerror
Living Standard No change from Unknown.
Unknown
AbstractWorker.onerror
Unknown Initial definition.

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 4 3.5 (1.9.1) 10 10.6 4
Feature Android Firefox Mobile (Gecko) Firefox OS (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 4.4 1.0 (1.9.1) 1.0.1 10 11.5 5.1

另请参阅

文档标签和贡献者

此页面的贡献者: liuzeyafzy
最后编辑者: liuzeyafzy,