Last active
December 18, 2015 19:19
-
-
Save fabioyamate/5831796 to your computer and use it in GitHub Desktop.
postMessage
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="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>postMessage</title> | |
</head> | |
<body> | |
<div id="container"> | |
iFrame | |
<button>post message</button> | |
</div> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> | |
<script> | |
$('button').on('click', function() { | |
window.parent.postMessage('post data message', 'https://rawgithub.com'); | |
}); | |
</script> | |
</body> | |
</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="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>postMessage</title> | |
</head> | |
<body> | |
<div id="container"> | |
<iframe src="https://rawgithub.com/fabioyamate/5831796/raw/iframe.html" id="iframe" border="1"></iframe> | |
</div> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> | |
<script> | |
$(window).bind('message', function(e) { | |
var event = e.originalEvent; | |
alert('origin: ' + event.origin); | |
alert('data: ' + event.data); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment