Last active
March 27, 2019 22:31
-
-
Save ilearnjavascript/c9095d2d5bb1e74d176372502faac31d to your computer and use it in GitHub Desktop.
plainjs - window.postmessage and iframes - 1.js
This file contains 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
function receiveMessage(event) { | |
if (event.origin === "http://iframe.com" | |
&& event.data === "message we expect") { | |
// execute code | |
} | |
} | |
// event listener for message event | |
window.addEventListener("message", receiveMessage, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment