Created
November 9, 2022 06:41
-
-
Save jabed-web-dev/f2025dc3666db27f78af6b958f0ac36a to your computer and use it in GitHub Desktop.
Handle the post message inside the frame window
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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