EventSource.onerror
EventSource
的属性 onerror
是当发生错误且这个错误事件(error
)被 EventSource 触发时调用的一个事件处理函数。
语法
eventSource.onerror = function
例子
js
evtSource.onerror = function () {
console.log("EventSource failed.");
};
备注: 你可以在 Github 上查看这个完整例子: Simple SSE demo using PHP.
规范
Specification |
---|
HTML Standard # event-error |
HTML Standard # handler-eventsource-onerror |
浏览器兼容性
BCD tables only load in the browser