Skip to content

Instantly share code, notes, and snippets.

@samir-plusb
Forked from kylewelsby/index.html
Last active October 10, 2016 23:22
Show Gist options
  • Save samir-plusb/9b76f5991ab0fca7078b44d5a84fb055 to your computer and use it in GitHub Desktop.
Save samir-plusb/9b76f5991ab0fca7078b44d5a84fb055 to your computer and use it in GitHub Desktop.
postMessage Example
<html>
<head>
<script>
var count=0;
function sendMessage() {
window.parent.postMessage(
JSON.stringify({
url: 'http://heise.de',
plus: 21,
minus: 42,
info: 'das ist meine info'}), // A stringified message to send.
"*" // The intended origin, in this example we use the any origin wildcard.
);
}
setInterval(function(){
sendMessage(); // Send a message every second
},1000);
</script>
</head>
<body>
<p>child window on different domain <a href="">GitHub Gist</a></p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment