We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

EventSource接口的 onopen 属性是一个 EventHandler ,它在收到open 事件时被调用,在那时,连接刚被打开。


eventSource.onopen = function


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

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


Specification Status Comment
HTML Living Standard
Living Standard Initial definition


We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
支持EventSource 6 未实现 6.0 (6.0) 未实现 (Yes) 5
在共享和专用的 workers上可用[1] (Yes) 未实现 53.0 (53.0) 未实现 (Yes) (Yes)
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
支持EventSource 4.4 45 未实现 12 4.1
在共享和专用的 workers上可用 [1] (Yes) 53.0 (53.0) 未实现 (Yes) (Yes)

[1] 但 目前不能在service workers上使用.



此页面的贡献者: kameii
最后编辑者: kameii,