Unable to send message from Iframe to parent

Options

I am using window.postMessage() to do a communication between iframe and my custom parent app where I have embedded domo dashboard.

Sending from DOMO DDX Brick:

const message = "Message from child DOMO Brick";   

window.parent.postMessage(message, "*");

And in my app I am getting it like this(where my dashbiard is embedded),

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

console.log("Message received from the child: " + event.data);

// Message received from child       

});

But this event is not firing. I am firing this event on the domo.onFiltersUpdate((e) => {}) function to fire this everytime. But its not even firing once.

Answers

  • MattTheGuru
    MattTheGuru Contributor
    Options

    Your issue is with the: window.parent.postMessage(message, "*");

    Domo won't approve of the "*" you need to do the following:

    // Replace "https://clearsquare-co-partner.domo.com" with the origin of the parent
    window.parent.postMessage(message, "https://clearsquare-co-partner.domo.com");


    Please 💡/💖/👍/😊 this post if you read it and found it helpful.
    Please accept the answer if it solved your problem.

  • muhammadtalha
    Options

    @MattTheGuru Thanks for this.

    I actually resolved this by just changing parent to top.

    so it became, window.top.postMessage(), I think the issue was with parent and child iframe window.