过时
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
close()
方法在
WorkerGlobalScope
interface discards any tasks queued in the
WorkerGlobalScope
's event loop, effectively closing this particular scope.
self.close();
If you wanted to close your worker instance from inside the worker itself, you could call the following:
close();
close()
and
self.close()
are effectively equivalent — both represent
close()
being called from inside the worker's inner scope.
注意
: there is also a way to stop the worker from the main thread: the
Worker.terminate
方法。
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
close
弃用
非标
|
Chrome 4 | Edge 12 | Firefox 3.5 | IE Yes | Opera 11.5 | Safari 4 | WebView Android 37 | Chrome Android Yes | Firefox Android 4 | Opera Android ? | Safari iOS ? | Samsung Internet Android Yes |
close()
moved to
DedicatedWorkerGlobalScope
and
SharedWorkerGlobalScope
|
Chrome 52 | Edge ≤79 | Firefox 54 | IE ? | Opera ? | Safari ? | WebView Android 52 | Chrome Android 52 | Firefox Android 54 | Opera Android ? | Safari iOS ? | Samsung Internet Android 6.0 |
完整支持
兼容性未知
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。