Created
March 27, 2019 22:37
-
-
Save ilearnjavascript/8edbf5e143c962b8f3e85c1997614aac to your computer and use it in GitHub Desktop.
plainjs - window.postmessage and iframes - 6.html
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
<!DOCTYPE html> | |
<html lang="de"> | |
<head> | |
<meta charset="utf-8"> | |
<title>iframe</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body> | |
<h1>iframe</h1> | |
<button>Trigger postMessage</button> | |
<div id="innerContainer"></div> | |
</body> | |
<script> | |
document.querySelector("button").addEventListener("click", function() { | |
top.postMessage("message from iframe", 'http://127.0.0.1:8080'); | |
}); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment