Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7878021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:32:30+00:00 2026-06-03T03:32:30+00:00

I have a web application with an iframe that needs to communicate with its

  • 0

I have a web application with an iframe that needs to communicate with its hosting page. The iframe and the host are on different domains and protocols (the iframe is https, the main page http). I use postMessage to get a small bit of state (user tracking) from the outer page into the iframe.

When the iframe is loaded, it sends a short message out to the top page to ask for the visitorid:

if ($.w.top != $.w) $.f.postMessage($.w.top, 'Get visitorId');

($.f.postMessage(w, m) is just a wrapper around postMessage, that does nothing if typeof w.postMessage === ‘undefined’). On the outer page, we have a message listener:

// Set up event listener so that we can respond when any iframes
// inside of us ask for our visitorId
$.f.listen($.w, 'message', giveVisitorId);
function giveVisitorId(event) {
  $.w['zzzzz'] = event.source;
  if (event.data === 'Get visitorId') {
    alert('about to reply from '+window.location.href+' with visitorid, typeof event.source.postMessage is ' + typeof(event.source.postMessage));
    event.source.postMessage('visitorId=' + $.v.visitorId, '*');
  }
}

The inner frame has a listener registered for the response:

$.f.listen($.w, 'message', receiveVisitorId);

function receiveVisitorId(event) {
  alert('receiveVisitorId called with: ' + event.data + ' in window '+window.location.href);
  var s = event.data.split('=');
  if (s[0] === 'visitorId' && s.length === 2) {
    $.v.visitorId = s[1];
    $.w.clearTimeout(giveUp);
    rest();
  }
}

This all works as it is supposed to on chrome and firefox on OSX (when the iframe is loaded we get two alerts, one from receiveVisitorId and one from giveVisitorId); however on IE8 on XP we only get the first alert (from giveVisitorId).

This is strange enough, since it seems that the postMessage going out works and the one going in doesn’t; what’s truly perplexing is that if we go to the console and run zzzzz.postMessage('hi', '*') the alert in receiveVisitorId happens just as expected! (Note that we saved event.source in window.zzzzz).

Does anyone have an idea why this might be happening?

PS: The definitions of $.w.listen and $.w.postMessage, for reference:

listen: function (el, ev, fn) {
  if (typeof $.w.addEventListener !== 'undefined') {
    el.addEventListener(ev, fn, false);
  }
  else if (typeof $.w.attachEvent !== 'undefined') {
    el.attachEvent('on' + ev, fn);
  }
},
postMessage: function(w, m) {
  if (typeof w.postMessage !== 'undefined') {
    w.postMessage(m, "*");
  }
},
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:32:32+00:00Added an answer on June 3, 2026 at 3:32 am

    We resolved it. The problem was that we were calling $.f.listen after $.f.postMessage in the inner iframe; so when the outer window posted a message to the inner, the listener had not yet been attached. I don’t know why this happened in IE and not chrome or firefox, but we just put it down to timing differences between the browsers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a ASP.Net MVC web application that needs to upload large files
We have an application that reconstructs external web sites in an Iframe from within
I have a Web application that is accessed via iframe, with user login. It
I have a web application that runs fine under IIS5 or IIS6. I just
I have a web application project that works with a quite large database (over
I have a web application that I am trying to port to Facebook. The
I have a legacy web application that was written long before there were even
I have a web application that allows the creation of HTML emails that can
I have an existing ASP.NET web application that I'm converting to MVC 1.0. The
I have written a web application that posts a file via http to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.