Created
April 23, 2013 15:29
-
-
Save chrisdeely/5444563 to your computer and use it in GitHub Desktop.
Simple postMessage example
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
<html> | |
<head> | |
<title>PostMessage test</title> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
function postIt(type, message){ | |
var eventData = {type: type, message:message}; | |
parent.postMessage(eventData, '*'); //allow any domain to receive the message | |
} | |
</script> | |
<button onclick="postIt('error','something went wrong')">Error</button> | |
<button onclick="postIt('success', 'no problemo')">Success</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment