Meteor overwrites in window.addEventListener

I want to pass the referer from a parent window to an iframe.

parent window:

 var src = document.getElementById('Iframe');
 src.contentWindow.postMessage("message", 'placeholderURL');

meteor app in iframe:

window.addEventListener('message', function(event) {

Getting the data with shows Meteor._setImmediate.0.9801140476483852.1 in the console.

Any idea? It works in non meteor apps.


Take a look at; this should help explain what you’re seeing.

Thanks. But i don´t see a solution. Can you help me out?

Sure - Meteor’s “message” event listener and your custom “message” event listener are interfering with each other. Meteor._setImmediate() in particular is causing you grief. Long story short though, if you just want to pass the referrer from the parent window to the iframe, why don’t you use URL parameters on the iframe URL instead? So in your parent window:

<iframe id="iframe" src=""></iframe>
  var iframe = document.getElementById('iframe');
  iframe.src = iframe.src + '?placeholderURL=someUrl';

You can then pull the custom parameters out of the URL in your iframe based Meteor app:


Thank you. I had something similar in mind, but thought there may be a meteor way.

Well, if you do want to use events you can always just make sure your event isn’t conflicting with Meteor “message” events. So something like this will work.

Parent window (make sure you’re firing the event after the iframe has loaded):

<iframe id="iframe" src="" onload="postIt();"></iframe>
  function postIt() {
    var iframe = document.getElementById('iframe');
    iframe.contentWindow.postMessage('some message!', '');

Somewhere in your Meteor iframe based app:

window.addEventListener('message', function (event) {
  // Make sure you're not trying to handle Meteor._setImmediate events
  if ('Meteor._setImmediate.') === -1) {