diff options
Diffstat (limited to 'files/zh-cn/web/api/broadcastchannel/close/index.html')
-rw-r--r-- | files/zh-cn/web/api/broadcastchannel/close/index.html | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/broadcastchannel/close/index.html b/files/zh-cn/web/api/broadcastchannel/close/index.html new file mode 100644 index 0000000000..e3eb201840 --- /dev/null +++ b/files/zh-cn/web/api/broadcastchannel/close/index.html @@ -0,0 +1,55 @@ +--- +title: BroadcastChannel.close() +slug: Web/API/BroadcastChannel/close +translation_of: Web/API/BroadcastChannel/close +--- +<p>{{APIRef("BroadCastChannel API")}}</p> + +<p>通过调用 <strong><code>BroadcastChannel.close()</code></strong> 方法,可以马上断开其与对应频道的关联,并让其被垃圾回收。这是必要的步骤,因为浏览器没有其它方式知道频道不再被需要。</p> + +<p>{{AvailableInWorkers}}</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox">var <em>str</em> = <em>channe<code>l</code></em><code>.close();</code> +</pre> + +<h2 id="示例">示例</h2> + +<pre class="brush: js">// 连接到指定频道 +var bc = new BroadcastChannel('test_channel'); + +// 其它操作 (如: postMessage, …) + +// 当完成后,断开与频道的连接 +bc.close(); +</pre> + +<h2 id="规范">规范</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">规范</th> + <th scope="col">状态</th> + <th scope="col">备注</th> + </tr> + <tr> + <td>{{SpecName('HTML WHATWG', "comms.html#dom-broadcastchannel-close", "BroadcastChannel.close()")}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + + + +<p>{{Compat("api.BroadcastChannel.close")}}</p> + +<h2 id="另见">另见</h2> + +<ul> + <li>{{domxref("BroadcastChannel")}}, the interface it belongs to.</li> +</ul> |