javascript - Either postMessage or addEventListener not working -


the following javascript code uses html5 postmessage / addeventlistener functions send message itself:

window.addeventlistener('testmsg', function(event) {    alert('got message');   /* never happens. why? */ }, false );  window.addeventlistener('load', function(event) {    alert('sending message');        window.postmessage('testmsg', '*'); }, false); 

a corresponding fiddle:

http://jsfiddle.net/zgvlg/3/

the message never received. reason?

i have modified fiddle. listening wrong event.

fiddle

should be

window.addeventlistener('message', function(event) {     alert('got message');   /* never happens. why? */ }, false );  window.addeventlistener('load', function(event) {     alert('sending message');         window.postmessage('message', '*'); }, false); 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -