1. 개발자를 위한 웹 기술
  2. Web API
  3. EventSource
  4. error

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

EventSource: error 이벤트

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2020년 1월.

참고 : 이 기능은 Web Worker에서 사용할 수 있습니다.

EventSource API의 error 이벤트는 이벤트 소스와의 연결을 열 수 없을 때 발생합니다.

이 이벤트는 취소할 수 없으며 버블링되지 않습니다.

구문

addEventListener()와 같은 메서드에서 이벤트 이름을 사용하거나, 이벤트 핸들러 속성을 설정합니다.

js
addEventListener("error", (event) => { })
onerror = (event) => { }

이벤트 타입

일반적인 Event입니다.

예제

js
const evtSource = new EventSource("sse.php");
// addEventListener version
evtSource.addEventListener("error", (e) => {
 console.log("An error occurred while attempting to connect.");
});
// onerror version
evtSource.onerror = (e) => {
 console.log("An error occurred while attempting to connect.");
};

명세서

Specification
HTML
# event-error
HTML
# handler-eventsource-onerror

브라우저 호환성

같이 보기

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.

AltStyle によって変換されたページ (->オリジナル) /