EventSource.onopen
EventSource
接口的 onopen
属性是一个 event handler
,它在收到open
事件时被调用,在那时,连接刚被打开。
语法
eventSource.onopen = function
示例
evtSource.onopen = function() {
console.log("Connection to server opened.");
};
注意 :你可以在 GitHub 上看到一个完整的示例— 请看 使用php的SSE(服务器发送事件)demo。
规范
Specification | Status | Comment |
---|---|---|
HTML Living Standard onopen |
Living Standard | Initial definition |
浏览器兼容性
No compatibility data found for api.EventSource.onopen
.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.