diff options
author | MDN <actions@users.noreply.github.com> | 2022-02-15 01:01:01 +0000 |
---|---|---|
committer | MDN <actions@users.noreply.github.com> | 2022-02-15 01:01:01 +0000 |
commit | e7754b8a0961a10a33c34819dbded4147c8aa1cc (patch) | |
tree | 8314b9c4ad8592ef4886d3085909c10ac54fed66 /files/zh-cn/conflicting/web | |
parent | a9eb67a3fafdfddd34fe6a7a33cc59ba7dfe9b60 (diff) | |
download | translated-content-e7754b8a0961a10a33c34819dbded4147c8aa1cc.tar.gz translated-content-e7754b8a0961a10a33c34819dbded4147c8aa1cc.tar.bz2 translated-content-e7754b8a0961a10a33c34819dbded4147c8aa1cc.zip |
[CRON] sync translated content
Diffstat (limited to 'files/zh-cn/conflicting/web')
-rw-r--r-- | files/zh-cn/conflicting/web/api/broadcastchannel/message_event/index.html | 56 | ||||
-rw-r--r-- | files/zh-cn/conflicting/web/api/broadcastchannel/messageerror_event/index.html | 46 |
2 files changed, 102 insertions, 0 deletions
diff --git a/files/zh-cn/conflicting/web/api/broadcastchannel/message_event/index.html b/files/zh-cn/conflicting/web/api/broadcastchannel/message_event/index.html new file mode 100644 index 0000000000..c5475fd880 --- /dev/null +++ b/files/zh-cn/conflicting/web/api/broadcastchannel/message_event/index.html @@ -0,0 +1,56 @@ +--- +title: BroadcastChannel.onmessage +slug: conflicting/Web/API/BroadcastChannel/message_event +translation_of: Web/API/BroadcastChannel/onmessage +original_slug: Web/API/BroadcastChannel/onmessage +--- +<p>{{APIRef("BroadCastChannel API")}}</p> + +<p>当 {{domxref("BroadcastChannel")}} 接收到类型为 {{domxref("MessageEvent")}} 的 {{event("message")}} 事件时,<code><strong>BroadcastChannel.onmessage</strong></code> 属性可以指定一个函数,作为该事件对应的事件处理程序来执行。</p> + +<p>{{AvailableInWorkers}}</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox"><em>channel</em>.onmessage = <em>function</em>; +</pre> + +<h3 id="值">值</h3> + +<ul> + <li><code>function</code> 是一个用户自定义函数的名称,不带 <code>()</code> 后续或参数;也可以是一个匿名函数,如 <code>function(event) {...}</code>。一个事件处理程序通常只有一个参数,包含了类型为 {{domxref("MessageEvent")}} 的事件。</li> +</ul> + +<h2 id="示例">示例</h2> + +<pre class="brush: js">bc.onmessage = function(ev) { console.log('message event received!'); }; +</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#handler-broadcastchannel-onmessage", "BroadcastChannel.onmessage")}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + + + +<p>{{Compat("api.BroadcastChannel.onmessage")}}</p> + +<h2 id="另见">另见</h2> + +<ul> + <li>一种在不同浏览器上下文之间通信的重量级方案:{{domxref("ServiceWorker")}}。</li> +</ul> diff --git a/files/zh-cn/conflicting/web/api/broadcastchannel/messageerror_event/index.html b/files/zh-cn/conflicting/web/api/broadcastchannel/messageerror_event/index.html new file mode 100644 index 0000000000..a87c54522e --- /dev/null +++ b/files/zh-cn/conflicting/web/api/broadcastchannel/messageerror_event/index.html @@ -0,0 +1,46 @@ +--- +title: BroadcastChannel.onmessageerror +slug: conflicting/Web/API/BroadcastChannel/messageerror_event +translation_of: Web/API/BroadcastChannel/onmessageerror +original_slug: Web/API/BroadcastChannel/onmessageerror +--- +<div>{{APIRef("HTML DOM")}}</div> + +<p>位于 {{domxref("BroadcastChannel")}} 接口上的 <code><strong>onmessageerror</strong></code> 事件处理程序,它是一个 {{domxref("EventListener", "事件监听器")}}。当 <code>BroadcastChannel</code> 接收到一条无法 {{glossary("Deserialization", "反序列化")}}的消息时,会触发类型为 {{domxref("MessageError")}} 的 {{domxref("MessageEvent")}} 事件,此时会执行该事件处理程序。</p> + +<p>{{AvailableInWorkers}}</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox">bc.onmessageerror = function() { ... };</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', '#handler-broadcastchannel-onmessageerror', 'onmessageerror')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td></td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<div> + + +<p>{{Compat("api.BroadcastChannel.onmessageerror")}}</p> +</div> + +<h2 id="另见">另见</h2> + +<ul> + <li><a href="/en-US/docs/Web/API/Channel_Messaging_API/Using_channel_messaging">Using channel messaging</a></li> +</ul> |