aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/windoworworkerglobalscope/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/api/windoworworkerglobalscope/index.html')
-rw-r--r--files/zh-cn/web/api/windoworworkerglobalscope/index.html182
1 files changed, 182 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/windoworworkerglobalscope/index.html b/files/zh-cn/web/api/windoworworkerglobalscope/index.html
new file mode 100644
index 0000000000..a0b3d68d14
--- /dev/null
+++ b/files/zh-cn/web/api/windoworworkerglobalscope/index.html
@@ -0,0 +1,182 @@
+---
+title: WindowOrWorkerGlobalScope
+slug: Web/API/WindowOrWorkerGlobalScope
+tags:
+ - API
+ - DOM
+ - DOM API
+ - Service Worker
+ - TopicStub
+ - Window
+ - WindowOrWorkerGlobalScope
+ - Worker
+ - WorkerGlobalScope
+translation_of: Web/API/WindowOrWorkerGlobalScope
+---
+<div>{{ApiRef()}}</div>
+
+<p><strong><code>WindowOrWorkerGlobalScope</code></strong> mixin 了对 {{domxref("Window")}} 和{{domxref("WorkerGlobalScope")}} 接口的公共特性的描述。显然除了下文即将列出的之外,这些接口中的每一个,都可以增加更多的特性。</p>
+
+<div class="note">
+<p><strong>Note</strong>: <code>WindowOrWorkerGlobalScope</code> 是一个 mixin 而并非 interface。不能创建一个类型为 <code>WindowOrWorkerGlobalScope 的对象。</code></p>
+</div>
+
+<h2 id="属性">属性</h2>
+
+<p>以下属性由 {{domxref("WindowOrWorkerGlobalScope")}} mixin 定义,同时被 {{domxref("Window")}} 和 {{domxref("WorkerGlobalScope")}} 实现。</p>
+
+<div id="Properties">
+<dl>
+ <dt>{{domxref("WindowOrWorkerGlobalScope.caches")}} {{readOnlyinline}}</dt>
+ <dd>返回与当前上下文相关联的 {{domxref("CacheStorage")}} 对象。这个对象提供了一些功能,例如存储可供离线使用的 asstes,以及对 requests 生成自定义的 responses 。</dd>
+ <dt>{{domxref("WindowOrWorkerGlobalScope.indexedDB")}} {{readonlyInline}}</dt>
+ <dd>提供一种机制,以供应用可以异步访问 indexed databases;返回 {{domxref("IDBFactory")}} 对象。</dd>
+ <dt>{{domxref("WindowOrWorkerGlobalScope.isSecureContext")}} {{readOnlyinline}}</dt>
+ <dd>返回一个 boolean 值, 表示当前上下文是否安全:安全返回 <code>true,<font face="Open Sans, arial, sans-serif">否则返回 </font></code><code>false 。</code></dd>
+ <dt>{{domxref("WindowOrWorkerGlobalScope.origin")}} {{readOnlyinline}}</dt>
+ <dd>返回全局对象的 origin,序列化为 string 。</dd>
+</dl>
+</div>
+
+<h2 id="方法">方法</h2>
+
+<p>以下方法由 {{domxref("WindowOrWorkerGlobalScope")}} mixin 定义,同时被 {{domxref("Window")}} 和 {{domxref("WorkerGlobalScope")}} 实现。</p>
+
+<dl>
+ <dt>{{domxref("WindowOrWorkerGlobalScope.atob()")}}</dt>
+ <dd>对 base-64加密的数据字符串进行解码。</dd>
+ <dt>{{domxref("WindowOrWorkerGlobalScope.btoa()")}}</dt>
+ <dd>从二进制数据中创建 base-64 编码的 ASCII 字符串。</dd>
+ <dt>{{domxref("WindowOrWorkerGlobalScope.clearInterval()")}}</dt>
+ <dd>取消对 {{domxref("WindowOrWorkerGlobalScope.setInterval()")}} 的重复执行。</dd>
+ <dt>{{domxref("WindowOrWorkerGlobalScope.clearTimeout()")}}</dt>
+ <dd>取消对 {{domxref("WindowOrWorkerGlobalScope.setTimeout()")}} 的延迟执行。</dd>
+ <dt>{{domxref("WindowOrWorkerGlobalScope.createImageBitmap()")}}</dt>
+ <dd>接受多个不同的图像源, 返回一个 {{domxref("Promise")}} which resolves to an {{domxref("ImageBitmap")}} 。可选: 指定 <em>(sx, sy)</em> with width sw, and height sh ,将源裁切成矩形。</dd>
+ <dt>{{domxref("WindowOrWorkerGlobalScope.fetch()")}}</dt>
+ <dd>开始从网络中 fetch 一个资源的进程。</dd>
+ <dt>{{domxref("WindowOrWorkerGlobalScope.setInterval()")}}</dt>
+ <dd>每过一个指定的毫秒时间后,执行一次指定函数。</dd>
+ <dt>{{domxref("WindowOrWorkerGlobalScope.setTimeout()")}}</dt>
+ <dd>过了一个指定的毫秒时间后,执行一次指定函数。</dd>
+</dl>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName("HTML WHATWG",'webappapis.html#windoworworkerglobalscope-mixin', '<code>WindowOrWorkerGlobalScope</code> mixin')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>This is where the main mixin is defined.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('Fetch','#fetch-method','fetch()')}}</td>
+ <td>{{Spec2('Fetch')}}</td>
+ <td>Definition of the <code>fetch()</code> method.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('Service Workers', '#self-caches', 'caches')}}</td>
+ <td>{{Spec2('Service Workers')}}</td>
+ <td>Definition of the <code>caches</code> property.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('IndexedDB 2', '#dom-windoworworkerglobalscope-indexeddb', 'indexedDB')}}</td>
+ <td>{{Spec2('IndexedDB 2')}}</td>
+ <td>Definition of the <code>indexedDB</code> property.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('Secure Contexts', 'webappapis.html#dom-origin', 'isSecureContext')}}</td>
+ <td>{{Spec2('Secure Contexts')}}</td>
+ <td>Definition of the <code>isSecureContext</code> property.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{CompatibilityTable}}</p>
+
+<table>
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Firefox (Gecko)</th>
+ <th>Chrome</th>
+ <th>Edge</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatGeckoDesktop(52)}}</td>
+ <td>54</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td><code>origin</code></td>
+ <td>{{CompatGeckoDesktop(54)}}</td>
+ <td>59</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+
+<table>
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android Webview</th>
+ <th>Edge</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>Android</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ <th>Chrome for Android</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoMobile(52)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>54</td>
+ </tr>
+ <tr>
+ <td><code>origin</code></td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoMobile(54)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>59</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{domxref("Window")}}</li>
+ <li>{{domxref("WorkerGlobalScope")}}</li>
+</ul>