Skip to content

Instantly share code, notes, and snippets.

@chrisdeely
Created April 23, 2013 15:29
Show Gist options
  • Save chrisdeely/5444563 to your computer and use it in GitHub Desktop.
Save chrisdeely/5444563 to your computer and use it in GitHub Desktop.
Simple postMessage example
<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