mirror of
https://github.com/Erreur32/html5demos.git
synced 2024-10-01 22:41:33 +02:00
21 lines
576 B
HTML
21 lines
576 B
HTML
|
<!DOCTYPE html>
|
||
|
<title>.postMessage target</title>
|
||
|
<style>
|
||
|
body {
|
||
|
font: normal 16px/20px Helvetica, sans-serif;
|
||
|
margin: 0;
|
||
|
padding: 20px;
|
||
|
}
|
||
|
</style>
|
||
|
<strong>This iframe is located on the same domain</strong>
|
||
|
<p id="test">Send me a message!</p>
|
||
|
<script src="h5utils.js"></script>
|
||
|
<script>
|
||
|
addEvent(window, "message", function(e){
|
||
|
if ( e.origin !== "http://html5demos.com" ) {
|
||
|
document.getElementById("test").innerHTML = 'Ignoring message from ' + e.origin;
|
||
|
} else {
|
||
|
document.getElementById("test").innerHTML = e.origin + " said: " + e.data;
|
||
|
}
|
||
|
});
|
||
|
</script>
|