Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Messaging - Receiving data
<!DOCTYPE html>
<html>
<head>
<title>Display Message</title>
<script>
function displayMessage(evt) {
var message;
if (evt.origin !== "http://nextechu.com") {
message = "You are not worthy";
}
else {
message = "I got " + evt.data + " from " + evt.origin;
}
document.getElementById("received-message").innerHTML = message;
}
window.addEventListener("message", displayMessage, false);
</script>
</head>
<body>
<p id="received-message">I've heard nothing yet</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment