概述
AbstractWorker
接口的onerror
特性是一个事件句柄,在 Worker
的error
事件触发并冒泡时执行。
语法
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 |
---|---|---|
WHATWG HTML Living Standard AbstractWorker.onerror |
Living Standard | No change from Web Workers. |
Web Workers AbstractWorker.onerror |
Editor's Draft | Initial definition. |
浏览器兼容性
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 |
另请参阅
- The
AbstractWorker
interface it belongs to.