WindowOrWorkerGlobalScope

WindowOrWorkerGlobalScope mixin describes several features common to the Window and WorkerGlobalScope 接口。 Each of these interfaces can, of course, add more features in addition to the ones listed below.

注意 : WindowOrWorkerGlobalScope is a mixin and not an interface; you can't actually create an object of type WindowOrWorkerGlobalScope .

特性

These properties are defined on the WindowOrWorkerGlobalScope mixin, and implemented by Window and WorkerGlobalScope .

WindowOrWorkerGlobalScope.caches 只读
返回 CacheStorage object associated with the current context. This object enables functionality such as storing assets for offline use, and generating custom responses to requests.
WindowOrWorkerGlobalScope.crossOriginIsolated 只读
Returns a boolean value that indicates whether a SharedArrayBuffer can be sent via a Window.postMessage() 调用。
WindowOrWorkerGlobalScope.indexedDB 只读
Provides a mechanism for applications to asynchronously access capabilities of indexed databases; returns an IDBFactory 对象。
WindowOrWorkerGlobalScope.isSecureContext 只读
Returns a boolean indicating whether the current context is secure ( true ) or not ( false ).
WindowOrWorkerGlobalScope.origin 只读
Returns the origin of the global scope, serialized as a string.

方法

These methods are defined on the WindowOrWorkerGlobalScope mixin, and implemented by Window and WorkerGlobalScope .

WindowOrWorkerGlobalScope.atob()
Decodes a string of data which has been encoded using base-64 encoding.
WindowOrWorkerGlobalScope.btoa()
Creates a base-64 encoded ASCII string from a string of binary data.
WindowOrWorkerGlobalScope.clearInterval()
Cancels the repeated execution set using WindowOrWorkerGlobalScope.setInterval() .
WindowOrWorkerGlobalScope.clearTimeout()
Cancels the delayed execution set using WindowOrWorkerGlobalScope.setTimeout() .
WindowOrWorkerGlobalScope.createImageBitmap()
Accepts a variety of different image sources, and returns a Promise which resolves to an ImageBitmap . Optionally the source is cropped to the rectangle of pixels originating at ( sx , sy ) with width sw , and height sh .
WindowOrWorkerGlobalScope.fetch()
Starts the process of fetching a resource from the network.
WindowOrWorkerGlobalScope.queueMicrotask()
Enqueues a microtask—a short function to be executed after execution of the JavaScript code completes and control isn't being returned to a JavaScript caller, but before handling callbacks and other tasks. This lets your code run without interfering with other, possibly higher priority, code, but before the browser runtime regains control, potentially depending upon the work you need to complete.
WindowOrWorkerGlobalScope.setInterval()
Schedules a function to execute every time a given number of milliseconds elapses.
WindowOrWorkerGlobalScope.setTimeout()
Schedules a function to execute in a given amount of time.

规范

规范 状态 Comment
HTML Living Standard
The definition of ' WindowOrWorkerGlobalScope mixin' in that specification.
实时标准 This is where the main mixin is defined.

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
WindowOrWorkerGlobalScope Chrome 4 Edge 12 Firefox 1 IE Yes Opera Yes Safari Yes WebView Android Yes Chrome Android 18 Firefox Android 4 Opera Android Yes Safari iOS Yes Samsung Internet Android 1.0
atob Chrome 4 Edge 12 Firefox 1
1
27
atob() ignores all space characters in the argument to comply with the latest HTML5 spec (see bug 711180 ).
57
atob() now defined on WindowOrWorkerGlobalScope mixin.
IE 10 Opera 10.5 Safari 3 WebView Android ≤37 Chrome Android 18 Firefox Android 4
4
27
atob() ignores all space characters in the argument to comply with the latest HTML5 spec (see bug 711180 ).
57
atob() now defined on WindowOrWorkerGlobalScope mixin.
Opera Android 11 Safari iOS 1 Samsung Internet Android 1.0
btoa Chrome 4 Edge 12 Firefox 1
1
52
btoa() now defined on WindowOrWorkerGlobalScope mixin.
IE 10 Opera 10.5 Safari 3 WebView Android ≤37 Chrome Android 18 Firefox Android 4
4
52
atob() now defined on WindowOrWorkerGlobalScope mixin.
Opera Android 11 Safari iOS 1 Samsung Internet Android 1.0
caches
Chrome 40 Edge ≤79 Firefox 42
42
52
caches now defined on WindowOrWorkerGlobalScope mixin.
IE No Opera ? Safari No WebView Android Yes Chrome Android Yes Firefox Android 42
42
52
caches now defined on WindowOrWorkerGlobalScope mixin.
Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
clearInterval Chrome 4 Edge 12 Firefox 1
1
52
clearInterval() now defined on WindowOrWorkerGlobalScope mixin.
IE 4
4
From Internet Explorer 4 through 8, clearInterval is an Object rather than a Function. This behavior was fixed in Internet Explorer 9.
Opera 4 Safari 4 WebView Android 1 Chrome Android 18 Firefox Android 4
4
52
clearInterval() now defined on WindowOrWorkerGlobalScope mixin.
Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0
clearTimeout Chrome 45 Edge 12 Firefox 1
1
52
clearTimeout() now defined on WindowOrWorkerGlobalScope mixin.
IE 4
4
From Internet Explorer 4 through 8, clearTimeout is an Object rather than a Function. This behavior was fixed in Internet Explorer 9.
Opera 4 Safari 4 WebView Android 45 Chrome Android 45 Firefox Android 4
4
52
clearTimeout() now defined on WindowOrWorkerGlobalScope mixin.
Opera Android 10.1 Safari iOS 1 Samsung Internet Android 5.0
createImageBitmap Chrome 50 Edge 79 Firefox 52
52
createImageBitmap() now defined on WindowOrWorkerGlobalScope mixin.
42
IE No Opera Yes Safari No WebView Android 50 Chrome Android 50 Firefox Android Yes Opera Android Yes Safari iOS ? Samsung Internet Android 5.0
crossOriginIsolated
非标
Chrome No Edge No Firefox 72 IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android No Opera Android No Safari iOS No Samsung Internet Android No
fetch
Chrome 42 Edge 14 Firefox 39
39
34
Disabled
Disabled From version 34: this feature is behind the dom.fetch.enable preference. To change preferences in Firefox, visit about:config.
52
fetch() now defined on WindowOrWorkerGlobalScope mixin.
IE No Opera 29
29
28
Disabled
Disabled From version 28: this feature is behind the Experimental Web Platform Features preference.
Safari 10.1 WebView Android 42 Chrome Android 42 Firefox Android 39
39
34
Disabled
Disabled From version 34: this feature is behind the dom.fetch.enable preference. To change preferences in Firefox, visit about:config.
52
fetch() now defined on WindowOrWorkerGlobalScope mixin.
Opera Android 29
29
28
Disabled
Disabled From version 28: this feature is behind the Experimental Web Platform Features preference.
Safari iOS 10.3 Samsung Internet Android 4.0
indexedDB Chrome 24 Edge 12 Firefox 16
16
10
Prefixed
Prefixed Implemented with the vendor prefix: moz
52
indexedDB now defined on WindowOrWorkerGlobalScope mixin.
IE 部分支持 10 Opera 15 Safari 7 WebView Android Yes Chrome Android 25 Firefox Android 22
22
52
indexedDB now defined on WindowOrWorkerGlobalScope mixin.
Opera Android 14 Safari iOS 8 Samsung Internet Android 2.0
isSecureContext
Chrome 55 Edge ≤79 Firefox 52 IE ? Opera ? Safari ? WebView Android 55 Chrome Android 55 Firefox Android 52 Opera Android ? Safari iOS ? Samsung Internet Android 6.0
origin Chrome 59 Edge ≤79 Firefox 54 IE No Opera No Safari No WebView Android 59 Chrome Android 59 Firefox Android 54 Opera Android No Safari iOS No Samsung Internet Android 7.0
queueMicrotask Chrome 71 Edge 79 Firefox 69 IE No Opera 58 Safari 12.1 WebView Android 71 Chrome Android 71 Firefox Android No Opera Android 50 Safari iOS 12.2 Samsung Internet Android 10.0
setInterval Chrome 30 Edge 12 Firefox 1
1
52
setInterval now defined on WindowOrWorkerGlobalScope mixin.
IE 4 Opera 4 Safari 1 WebView Android 4.4 Chrome Android 30 Firefox Android 4
4
52
setInterval now defined on WindowOrWorkerGlobalScope mixin.
Opera Android 10.1 Safari iOS 1 Samsung Internet Android 3.0
setTimeout Chrome 30 Edge 12 Firefox 1
1
52
setInterval now defined on WindowOrWorkerGlobalScope mixin.
IE 4 Opera 4 Safari 1 WebView Android 4.4 Chrome Android 30 Firefox Android 4
4
52
setInterval now defined on WindowOrWorkerGlobalScope mixin.
Opera Android 10.1 Safari iOS 1 Samsung Internet Android 3.0

图例

完整支持
完整支持
部分支持
部分支持
不支持
不支持
兼容性未知
兼容性未知
实验。期望将来行为有所改变。
实验。期望将来行为有所改变。
非标。预期跨浏览器支持较差。
非标。预期跨浏览器支持较差。
见实现注意事项。
用户必须明确启用此特征。
用户必须明确启用此特征。
要求使用供应商前缀或不同名称。
要求使用供应商前缀或不同名称。

另请参阅