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 8995715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:39:24+00:00 2026-06-15T23:39:24+00:00

I am having trouble using postMessage, even after reading other posts online and on

  • 0

I am having trouble using postMessage, even after reading other posts online and on this website.

I have an iframe that is generate using var abc_iframe = document.createElement(‘iframe’). From my understanding I am suppose to attach an event listener to this to listen to message from within the iframe.
I have tried:

1. abc_iframe.addEventListener("message", function(e){ console.log(e.data); }, false);
2. document.frames['id_iframe'].addEventListener("message", function(e){ console.log(e.data); }, false); 
(id_iframe right here being the id of the iframe)
3. WinJS.Application.addEventListener("message", function(e){ console.log(e.data); }, false);

None of these have worked.
I am sending the postMessage from within the iframe using

1. parent.postMessage("message", "ms-appx://" + document.location.host);
2. window.parent.postMessage("message", "ms-appx://" + document.location.host);

The iframe content is hosted on another domain (not locally).

  • 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-15T23:39:24+00:00Added an answer on June 15, 2026 at 11:39 pm

    You need to attach to the window object, not the iframe, to receive messages from the iframe.

    window.addEventListener(function(e) {}));
    

    In the message you send you should include info that lets the parent identify the iframe sending the message, as all messages from all windows will be processed by this event handler.

    Also note that addEventListener only works in some browsers. Older IE versions use attachEvent.

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

Sidebar

Related Questions

Anybody having trouble using AVFoundation with GC ON??? What I am experiencing is that
I'm having trouble using Short2 for the (x,y) positions in my vertex data. This
I am having trouble using JQuery with ASP.net. I have a HTML img ,
I'm having trouble using gsub correctly: Given this code: replace me.gsub(/replace me/, this \\0
I'm having trouble using contentEditable in FireFox 3. I have a problem where the
I'm having trouble using python function decorators in Google's AppEngine. I'm not that familiar
I'm having trouble using an argument from my class in one of that class's
I'm having trouble using a template bound multiple times. For instance this is fine:
I am having trouble using system() from libc on Linux. My code is this:
I am having trouble using nested ajax calls with selectors. I have a section

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.