Unable to send message from Iframe to parent
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
-
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");** Was this post helpful? Click 💡/💖/👍/😊 below. **
** If it solved your problem. Accept it as a solution! ✔️ **
Or do you need more help? https://calendly.com/matthew-kastner/15-minute-chat
Did I help you out? Feedback is priceless and will help me more than you know.Write a review!0 -
@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.
1 -
Can someone explain where this is being done on the DOMO side? I want to do something similar but don't know how to implement this on the DOMO side to then receive the message in my parent.
0 -
@AJ_Herold I implemented that, so you need to do the following two things to receive message in your parent from iframe.
1- send postmessage() from your iframe with a syntax like below:
let message= 'less_then_10';
window.top.postMessage(message, "*");
2: You need to make an event in your parent where you are using that iframe, to listen to this event like:
// Listen to message from child window
eventer(messageEvent, function(e)
{
// console.log('Event data : ', data);var data = e.data;
//run function//console.log('Event data : ', data);
});
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 738 Beast Mode
- 57 App Studio
- 40 Variables
- 685 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 124 Manage
- 121 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive