DedicatedWorkerGlobalScope
Baseline
Widely available
*
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
* Some parts of this feature may have varying levels of support.
DedicatedWorkerGlobalScope 对象(也就是 Worker 全局作用域)可以通过 self 关键字来访问。一些在 worker 全局作用域下不可用的全局函数、命名空间对象以及构造器,也可以通过此对象使用。在 JavaScript 参考的 Web Workers 可以使用的函数和类页面中,有列举这些特性。
实例属性
该接口从 WorkerGlobalScope 接口以及它的父接口 EventTarget 继承属性。
实例方法
该接口从 WorkerGlobalScope 接口以及它的父接口 EventTarget 继承方法。
WorkerGlobalScope.close()-
抛弃当前
WorkerGlobalScope的 event loop 中所有正在排队的任务,关闭当前作用域。 DedicatedWorkerGlobalScope.postMessage-
向该 worker 的父文档发送消息——消息可以是任何 Javascript 对象。
事件
message-
Fired when the worker receives a message from its parent. Also available via the
onmessageproperty. messageerror-
Fired when a worker receives a message that can't be deserialized. Also available via the
onmessageerrorproperty.
规范
| Specification |
|---|
| HTML> # dedicated-workers-and-the-dedicatedworkerglobalscope-interface> |
浏览器兼容性
Loading…