From ba8d3f6f9d418e3b7fdfe79ccfb6e7a6ffb7f566 Mon Sep 17 00:00:00 2001 From: MDN Date: Sat, 12 Mar 2022 00:12:34 +0000 Subject: [CRON] sync translated content --- .../web/api/eventsource/open_event/index.html | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 files/zh-cn/web/api/eventsource/open_event/index.html (limited to 'files/zh-cn/web/api/eventsource/open_event/index.html') diff --git a/files/zh-cn/web/api/eventsource/open_event/index.html b/files/zh-cn/web/api/eventsource/open_event/index.html new file mode 100644 index 0000000000..64214dbd2f --- /dev/null +++ b/files/zh-cn/web/api/eventsource/open_event/index.html @@ -0,0 +1,57 @@ +--- +title: EventSource.onopen +slug: Web/API/EventSource/open_event +tags: + - API + - Event Handler + - EventSource +translation_of: Web/API/EventSource/onopen +original_slug: Web/API/EventSource/onopen +--- +
{{APIRef('WebSockets API')}}
+ +

{{domxref("EventSource")}}接口的 onopen 属性是一个 {{event("Event_handlers", "event handler")}} ,它在收到{{event("open")}} 事件时被调用,在那时,连接刚被打开。

+ +

语法

+ +
eventSource.onopen = function
+ +

示例

+ +
evtSource.onopen = function() {
+  console.log("Connection to server opened.");
+};
+ +
+

注意 :你可以在 GitHub 上看到一个完整的示例— 请看 使用php的SSE(服务器发送事件)demo。

+
+ +

规范

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "comms.html#handler-eventsource-onopen", "onopen")}}{{Spec2('HTML WHATWG')}}Initial definition
+ + + +

浏览器兼容性

+ +{{Compat("api.EventSource.onopen")}} + +

相关链接

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