javascript - Why my postMessage does not work on chrome and firefox? -


i made 2 pages, page a.html is:

<script> var popup = window.open("b.html");  popup.postmessage("hello there!", "*");  function receivemessage(event) {     alert(event.data); } window.addeventlistener("message", receivemessage, false);  </script> 

and page b.html

<script> function receivemessage(event) {     alert(event.data);     event.source.postmessage("hi there yourself!", "*"); }  window.addeventlistener("message", receivemessage, false); </script> 

if open a.html in ie, can these scripts work , alert() popup message on each of page. however, when load a.html in chrome or firefox, open b.html in window , alert() won't executed @ all. why?


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -