WindowOrWorkerGlobalScope mixin 了对 Window 和WorkerGlobalScope 接口的公共特性的描述。显然除了下文即将列出的之外,这些接口中的每一个,都可以增加更多的特性。
Note: WindowOrWorkerGlobalScope 是一个 mixin 而并非 interface。不能创建一个类型为 WindowOrWorkerGlobalScope 的对象。
属性
以下属性由 WindowOrWorkerGlobalScope mixin 定义,同时被 Window 和 WorkerGlobalScope 实现。
WindowOrWorkerGlobalScope.caches只读- 返回与当前上下文相关联的
CacheStorage对象。这个对象提供了一些功能,例如存储可供离线使用的 asstes,以及对 requests 生成自定义的 responses 。 WindowOrWorkerGlobalScope.indexedDB只读- 提供一种机制,以供应用可以异步访问 indexed databases;返回
IDBFactory对象。 WindowOrWorkerGlobalScope.isSecureContext只读- 返回一个 boolean 值, 表示当前上下文是否安全:安全返回
true,否则返回false 。 WindowOrWorkerGlobalScope.origin只读- 返回全局对象的 origin,序列化为 string 。
方法
以下方法由 WindowOrWorkerGlobalScope mixin 定义,同时被 Window 和 WorkerGlobalScope 实现。
WindowOrWorkerGlobalScope.atob()- 对 base-64加密的数据字符串进行解码。
WindowOrWorkerGlobalScope.btoa()- 从二进制数据中创建 base-64 编码的 ASCII 字符串。
WindowOrWorkerGlobalScope.clearInterval()- 取消对
WindowOrWorkerGlobalScope.setInterval()的重复执行。 WindowOrWorkerGlobalScope.clearTimeout()- 取消对
WindowOrWorkerGlobalScope.setTimeout()的延迟执行。 WindowOrWorkerGlobalScope.createImageBitmap()- 接受多个不同的图像源, 返回一个
Promisewhich resolves to anImageBitmap。可选: 指定 (sx, sy) with width sw, and height sh ,将源裁切成矩形。 WindowOrWorkerGlobalScope.fetch()- 开始从网络中 fetch 一个资源的进程。
WindowOrWorkerGlobalScope.setInterval()- 每过一个指定的毫秒时间后,执行一次指定函数。
WindowOrWorkerGlobalScope.setTimeout()- 过了一个指定的毫秒时间后,执行一次指定函数。
Specifications
| Specification | Status | Comment |
|---|---|---|
WHATWG HTML Living StandardWindowOrWorkerGlobalScope mixin |
Living Standard | This is where the main mixin is defined. |
| Fetch fetch() |
Living Standard | Definition of the fetch() method. |
| Service Workers caches |
Working Draft | Definition of the caches property. |
| Indexed Database API 2.0 indexedDB |
Editor's Draft | Definition of the indexedDB property. |
| Secure Contexts isSecureContext |
Working Draft | Definition of the isSecureContext property. |
Browser compatibility
| Feature | Firefox (Gecko) | Chrome | Edge | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| Basic support | 52 (52) | 54 | ? | ? | ? | ? |
origin |
54 (54) | 59 | ? | ? | ? | ? |
| Feature | Android Webview | Edge | Firefox Mobile (Gecko) | Android | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
|---|---|---|---|---|---|---|---|---|
| Basic support | ? | ? | 52.0 (52) | ? | ? | ? | ? | 54 |
origin |
? | ? | 54.0 (54) | ? | ? | ? | ? | 59 |