Window postMessage API

The postMessage API involves two roles:

  • Sender Window: Sends a message to another window using postMessage().

  • Receiver Window: Listens for the message and processes the received data.

Receiver Window

  • Listens for messages with addEventListener('message')

  • Updates the paragraph content with the message

Sender Window

  • Opens the receiver window with window.open().

  • Sends a message using postMessage() when the button is clicked

Last updated