From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../api/broadcastchannel/postmessage/index.html | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 files/zh-cn/web/api/broadcastchannel/postmessage/index.html (limited to 'files/zh-cn/web/api/broadcastchannel/postmessage') diff --git a/files/zh-cn/web/api/broadcastchannel/postmessage/index.html b/files/zh-cn/web/api/broadcastchannel/postmessage/index.html new file mode 100644 index 0000000000..374c611b34 --- /dev/null +++ b/files/zh-cn/web/api/broadcastchannel/postmessage/index.html @@ -0,0 +1,44 @@ +--- +title: BroadcastChannel.postMessage() +slug: Web/API/BroadcastChannel/postMessage +translation_of: Web/API/BroadcastChannel/postMessage +--- +

{{APIRef("BroadCastChannel API")}}

+ +

可以使用 BroadcastChannel.postMessage() 发送一条任意 {{jsxref("Object")}} 类型的消息,给所有同{{glossary("origin", "源")}}下监听了该频道的所有{{glossary("browsing context", "浏览器上下文")}}。消息以 {{event("message")}} 事件的形式发送给每一个绑定到该频道的广播频道。

+ +

{{AvailableInWorkers}}

+ +

语法

+ +
var str = channel.postMessage(object);
+
+ +

规范

+ + + + + + + + + + + + + + +
规范状态备注
{{SpecName('HTML WHATWG', "comms.html#dom-broadcastchannel-postmessage", "BroadcastChannel.postmessage()")}}{{Spec2('HTML WHATWG')}}Initial definition.
+ +

浏览器兼容性

+ + + +

{{Compat("api.BroadcastChannel.postMessage")}}

+ +

另见

+ + -- cgit v1.2.3-54-g00ecf