37 lines
830 B
HTML
37 lines
830 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head><title>Testing message passing across windows</title>
|
|
|
|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
|
|
<style type="text/css">
|
|
#another-world {
|
|
width: 100%;
|
|
height: 50%;
|
|
}
|
|
</style>
|
|
|
|
</head>
|
|
<body>
|
|
<p>This is a world program:</p>
|
|
<iframe id="another-world" src="js-get-message-child.html"></iframe>
|
|
|
|
<br/>
|
|
<hr/
|
|
<p>And this a regular JavaScript program:</p>
|
|
<input id="msg" type="text"/>
|
|
<input id="submit" type="submit">
|
|
|
|
|
|
<script type="text/javascript">
|
|
$(document).ready(function() {
|
|
var otherWorld = document.getElementById("another-world").contentWindow;
|
|
var send = function() {
|
|
otherWorld.postMessage($("#msg").val(), "*");
|
|
$("#msg").val("");
|
|
};
|
|
$("#submit").on("click", send);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|