Skip to content

One way usage

Andrei Cojocari edited this page Dec 2, 2021 · 3 revisions

Send a message to another frame.


// Frame A: send a message to frame B
sendPostMessage({
  target: frameB,
  eventName: "hello",
  data: { foo: "bar" },
});

// Frame B: receive message from frame A
onPostMessage({
  eventName: "hello",
  callback: (event, data) => {
    console.log(data); // output: { foo: 'bar' }
  },
});
Clone this wiki locally