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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:46:04+00:00 2026-06-11T06:46:04+00:00

Im trying to get some html5 post messaging going with dojo 1.8, i’ve created

  • 0

Im trying to get some html5 post messaging going with dojo 1.8, i’ve created a jsfiddle to try to explain it better. One thing to note is that the button is being loaded within the iframe. So basically if a click happens within the iframe then the parent node should receive and act upon the message. Any pointers would be appreciated.

http://jsfiddle.net/AvPFv/

  • 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-11T06:46:06+00:00Added an answer on June 11, 2026 at 6:46 am

    Basically, you should listen for message on iframe window, i.e. iframe.contentWindow. Also, please note there is no dojo in your iframe.

    I created a jsFiddle to show how it works: http://jsfiddle.net/phusick/H7Zh8/ but I’m afraid it is very messy to have everything in a single file, i.e. in the context of the parent window, because it does not explain properly where window reference points to and it does not simulate real world usage. I suggest you try it at localhost having two sets of scripts, one for parent window and one for iframe.

    require([
        "dojo/dom",
        "dojo/on",
        "dojo/date/locale",
        "dojo/domReady!"        
    ], function(
        dom,
        on,
        locale    
    ) {
    
        var buttonNode = dom.byId("postMessageButton");
        var iframeNode = dom.byId("iframe");
        var iframe = iframeNode.contentWindow;
        var iframeButtonNode = iframe.document.getElementById("postMessageButton");
    
        on(buttonNode, "click", function() {
            iframe.postMessage("hello from parent", "*");       
        });
    
        on(iframe, "message", function(event) {
            var msgNode = iframe.document.getElementById("msg");
            msgNode.innerHTML += formatMessage(event);
            event.source.postMessage("echo from iframe", "*");
        });
    
        on(iframeButtonNode, "click", function() {
            iframe.parent.postMessage("hello from iframe", "*");
        })
    
        on(window, "message", function(event) {
            dom.byId("msg").innerHTML += formatMessage(event);
        });
    
    
        function formatMessage(event) {
            var time = locale.format(new Date(event.timeStamp),{
                selector: "time",
                formatLength: "medium"
            });
            return time + ": " + event.data + "<br>";
        }
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been going bananas trying to get some data from Javascript on one page
I am trying to post some data and get some data back from a
According to my previous post I am trying to get back some information from
I am trying to get country where some specific post exists, so that I
I'm trying to use jQuery.post() function to retrieve some data. But i get no
I am having troubles while trying to post some datas with one file (an
I'm trying to test out html5 localStorage feature. For some reason, whenever I try
I'm stuck at this part.. Trying to get a simple AjaxPost to post some
I'm trying to get some HTML to work with my python code. I've got
I am trying to get some content in html documents. Some of the documents

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.