close() 方法在 DedicatedWorkerGlobalScope interface discards any tasks queued in the DedicatedWorkerGlobalScope 's event loop, effectively closing this particular scope.

句法

self.close();
					

范例

If you want to close your worker instance from inside the worker itself, you can 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 方法。

规范

规范 状态 注释
HTML 实时标准
The definition of 'close()' in that specification.
实时标准

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
close Chrome Yes Edge ≤79 Firefox 54 IE ? Opera Yes Safari ? WebView Android Yes Chrome Android Yes Firefox Android 54 Opera Android Yes Safari iOS ? Samsung Internet Android Yes

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

另请参阅

DedicatedWorkerGlobalScope

元数据

  • 最后修改: