Skip to content

Instantly share code, notes, and snippets.

@jabed-web-dev
Created November 9, 2022 06:41
Show Gist options
  • Select an option

  • Save jabed-web-dev/f2025dc3666db27f78af6b958f0ac36a to your computer and use it in GitHub Desktop.

Select an option

Save jabed-web-dev/f2025dc3666db27f78af6b958f0ac36a to your computer and use it in GitHub Desktop.
Handle the post message inside the frame window
// Handle the post message inside the frame window
// index.html
frame.onload = () => {
setTimeout(() => {
window.frames.frame.postMessage("hello Frame", "*");
}, 5000)
}
// Handle the message from the parent window
// frame.html
window.addEventListener('load', () => {
window.addEventListener('message', event => {
const message = event.data; // The JSON data our extension sent
console.log(message)
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment