EventSource: open 이벤트
        
        
          
                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 인터페이스의 open 이벤트는 이벤트 소스와의 연결이 열릴 때 발생합니다.
이 이벤트는 취소할 수 없으며, 버블링되지 않습니다.
구문
addEventListener() 같은 메서드에서 이벤트 이름을 사용하거나 이벤트 핸들러 속성을 설정합니다.
js
addEventListener("open", (event) => { })
onopen = (event) => { }
이벤트 타입
일반적인 Event 객체입니다.
예제
js
const evtSource = new EventSource("sse.php");
// addEventListener version
evtSource.addEventListener("open", (e) => {
  console.log("The connection has been established.");
});
// onopen version
evtSource.onopen = (e) => {
  console.log("The connection has been established.");
};
명세서
| Specification | 
|---|
| HTML> # event-open>  | 
            
| HTML> # handler-eventsource-onopen>  | 
            
브라우저 호환성
Loading…