window.postMessage in insecure mode

153 views
Skip to first unread message

Netanel Livni

unread,
Oct 26, 2016, 9:35:27 AM10/26/16
to Interactive Media Ads SDK
I have an ad that creates an iframe in a different domain and then uses the postMessage method to communicate back and forth with the parent.  However, even though I add a message event listener on the parent window as follows:

goog.events.listen(
        window,
        goog.events.EventType.MESSAGE,
        this.onMessage_,
        false,
        this
    );

by the time the code in the frame makes the call to postMessage:

window.parent.postMessage('myMessage', '*');

It never gets received by the parent.

On closer examination, I have noticed that the event listener above was removed by the time the child sends the events.

Does anyone have any ideas what is removing the listener and why?  More importantly, how do I stop it from doing so?


Vu Chau (IMA SDK Team)

unread,
Oct 26, 2016, 11:15:50 AM10/26/16
to Interactive Media Ads SDK
Hi Netanel,

It shouldn't be a problem what you are doing, though.  The VPAID ad definitely doesn't remove listeners, so as far as that is concerned, this doesn't seem like an IMA SDK problem.  

What you could do is debug into your ad in Chrome and see whether the messages come through.  It's important that the window/frame you post the message to and the one you listen on are the same.

Vu Chau
IMA SDK Team
Reply all
Reply to author
Forward
0 new messages