AbstractWorker
.onerror
特性为
AbstractWorker
interface represents an
EventHandler
, that is a function to be called when the
error
event occurs and bubbles through the
Worker
.
myWorker.onerror = function() { ... };
The following code snippet shows creation of a
Worker
对象使用
Worker()
constructor and setting up of an
onerror
handler on the resulting object:
var myWorker = new Worker('worker.js');
myWorker.onerror = function() {
console.log('There is an error with your worker!');
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of 'AbstractWorker.onerror' in that specification. |
实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
onerror
|
Chrome 4 | Edge 12 | Firefox 3.5 | IE 10 | Opera 10.6 | Safari 4 | WebView Android 4.4 | Chrome Android 18 | Firefox Android 4 | Opera Android 11 | Safari iOS 5.1 | Samsung Internet Android 1.0 |
完整支持
In earlier browser versions, trying to load a cross-origin worker script threw a
SecurityError
; in newer browsers an
error
event is thrown instead due to a spec change. Find out more information on how to deal with this in
Loading cross-origin worker now fires error event instead of throwing; worker in sandboxed iframe no longer allowed
.
AbstractWorker
interface it belongs to.
AbstractWorker
onerror