Sunday, 15 February 2015

javascript - ReceiveMessage event showing data as undefined -



javascript - ReceiveMessage event showing data as undefined -

i have iframe in there javascript function:

function callparent(){ parent.postmessage('closemodal','*'); homecoming true; }

and other javascript function in main page:

$(window).on('message',function(e){ console.log(e); });

it's printing e in e.data it's giving undefined. expecting info string 'closemodal'.

how message string iframe?

the info you're passing in

e.originalevent.data

so on main page:

$(window).on('message',function(e){ console.log(e.originalevent.data); });

as pointy commented jquery creates own event object.

if not using jquery have had

window.onmessage = function(e){ console.log(e.data); };

javascript jquery iframe

No comments:

Post a Comment