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.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 755 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive