SharedWorkerGlobalScope
object (the
SharedWorker
global scope) is accessible through the
self
keyword. Some additional global functions, namespaces objects, and constructors, not typically associated with the worker global scope, but available on it, are listed in the
JavaScript 参考
. See the complete list of
functions available to workers
.
此接口继承的特性来自
WorkerGlobalScope
interface, and its parent
EventTarget
, and therefore implements properties from
WindowTimers
,
WindowBase64
,和
WindowEventHandlers
.
SharedWorkerGlobalScope.name
只读
SharedWorker
was (optionally) given when it was created using the
SharedWorker()
constructor. This is mainly useful for debugging purposes.
SharedWorkerGlobalScope.applicationCache
只读
ApplicationCache
object for the worker (see
Using the application cache
).
WorkerGlobalScope.self
DedicatedWorkerGlobalScope
对象自身。
WorkerGlobalScope.console
只读
控制台
associated with the worker.
WorkerGlobalScope.location
只读
WorkerLocation
associated with the worker.
WorkerLocation
is a specific location object, mostly a subset of the
定位
for browsing scopes, but adapted to workers.
WorkerGlobalScope.navigator
只读
WorkerNavigator
associated with the worker.
WorkerNavigator
is a specific navigator object, mostly a subset of the
Navigator
for browsing scopes, but adapted to workers.
WorkerGlobalScope.performance
只读
性能
object associated with the worker, which is a regular performance object, but with a subset of its properties and methods available.
This interface inherits event handlers from the
WorkerGlobalScope
interface, and its parent
EventTarget
, and therefore implements event handlers from
WindowTimers
,
WindowBase64
,和
WindowEventHandlers
.
SharedWorkerGlobalScope.onconnect
EventHandler
表示要调用的代码当
connect
event is raised — that is, when a
MessagePort
connection is opened between the associated
SharedWorker
and the main thread.
此接口继承的方法来自
WorkerGlobalScope
interface, and its parent
EventTarget
, and therefore implements methods from
WindowTimers
,
WindowBase64
,和
WindowEventHandlers
.
SharedWorkerGlobalScope.close()
SharedWorkerGlobalScope
's event loop, effectively closing this particular scope.
WorkerGlobalScope.close()
WorkerGlobalScope
's event loop, effectively closing this particular scope.
WorkerGlobalScope.dump()
window.dump
, but for workers.
WorkerGlobalScope.importScripts()
importScripts('foo.js', 'bar.js');
WindowBase64.atob()
Decodes a string of data which has been encoded using base-64 encoding.
WindowBase64.btoa()
Creates a base-64 encoded ASCII string from a string of binary data.
WindowTimers.clearInterval()
WindowTimers.setInterval()
.
WindowTimers.clearTimeout()
WindowTimers.setTimeout()
.
WindowTimers.setInterval()
Schedules the execution of a function every X milliseconds.
WindowTimers.setTimeout()
Sets a delay for executing a function.
Listen to this event using
addEventListener()
或通过把事件监听器赋值给
on
eventname
特性为此接口。
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of 'SharedWorkerGlobalScope' in that specification. |
实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
SharedWorkerGlobalScope
|
Chrome 4 | Edge ≤79 | Firefox 29 | IE No | Opera 10.6 | Safari 5 | WebView Android Yes | Chrome Android Yes | Firefox Android 4 | Opera Android 11 | Safari iOS 7 | Samsung Internet Android Yes |
applicationCache
|
Chrome 4 | Edge ≤79 | Firefox 29 | IE No | Opera 10.6 | Safari No | WebView Android Yes | Chrome Android Yes | Firefox Android 29 | Opera Android Yes | Safari iOS ? | Samsung Internet Android Yes |
close
|
Chrome No | Edge No | Firefox 54 | IE No | Opera No | Safari ? | WebView Android No | Chrome Android No | Firefox Android 54 | Opera Android No | Safari iOS ? | Samsung Internet Android No |
connect
event
|
Chrome 4 | Edge ≤79 |
Firefox
29
|
IE No | Opera 10.6 | Safari No | WebView Android Yes | Chrome Android 18 |
Firefox Android
29
|
Opera Android Yes | Safari iOS ? | Samsung Internet Android 1.0 |
名称
|
Chrome Yes | Edge ≤79 | Firefox 55 | IE No | Opera 10.6 | Safari No | WebView Android Yes | Chrome Android 40 | Firefox Android 55 | Opera Android Yes | Safari iOS No | Samsung Internet Android 4.0 |
onconnect
|
Chrome 4 | Edge ≤79 | Firefox 29 | IE No | Opera 10.6 | Safari No | WebView Android Yes | Chrome Android 18 | Firefox Android 29 | Opera Android Yes | Safari iOS ? | Samsung Internet Android 1.0 |
完整支持
不支持
兼容性未知
见实现注意事项。