DOM

settings_applicationsEventTarget  >   settings_applicationsWindow

DOM

Editing
  • bug_report

Eventmessage

연관된 또 다른 window와 서로 메시지를 주고 받는 경우 발생한다.

insert_drive_fileMessageEventinterfaceopen_in_new
MessageEvent interface는 Window에서 message 이벤트 타입으로 구현된다.

Window의 message는 MessageEvent interface의 이벤트 타입이고 이벤트 리스너에서 사용된다.

기본 개요

window.postMessage()를 호출하여 창이 메시지를 받았을 때 발생한다.

설명

메시지를 주고 받을 수 있는 window는 다음과 같다.

  • window.opener : window.open()으로 새로운 창을 연 경우
  • window.parent : <iframe>으로 문서 내 프레임을 생성한 경우
  • window.frames[index]<iframe>으로 문서 내 프레임을 생성한 경우
  • HTMLIFrameElement.contentWindow<iframe>으로 문서 내 프레임을 생성한 경우

설명

메시지를 주고 받을 수 있는 window는 다음과 같다.

  • window.opener : window.open()으로 새로운 창을 연 경우
  • window.parent : <iframe>으로 문서 내 프레임을 생성한 경우
  • window.frames[index]<iframe>으로 문서 내 프레임을 생성한 경우
  • HTMLIFrameElement.contentWindow<iframe>으로 문서 내 프레임을 생성한 경우

구문

형식
window.addEventListener("message", function() {});

명세

typemessage
bubblesno
cancelableno
targetBroadcastChannel, EventSource, MessagePort, ServiceWorkerContainer, window, Worker
handleryes

버전 명세

HTML Standard API
#event-message

지원 웹브라우저