How to pass events between a custom Next Experience Page and a child iframe in UI Builder?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2022 08:06 PM
Hello, I'm building a custom page with UI Builder. It contains an external web application loading in an iframe that is rendered by my custom component. I need my page and the external app to exchange event messages. The only way I know how to do this is with Window.postMessage and Window.addEventListener. My plan was to make those calls from client scripts configured as event handlers. However, in UIB I can't find a way to get a reference to the 'window' global variable to access the window in the iframe. Any ideas would be most welcome. Is this possible in the Now Experience UI Framework?
Note: I control the code for the external web app so I can pursue alternative solutions if they exist. And I can access the 'window' global var in that application without any issues.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2022 10:16 AM
You won't have access to window from within a UIB page script. You'll need to do the communication from within your custom component and then use properties and events to communicate with the UIB page.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2022 08:28 PM
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2022 07:33 AM
Just to confirm, you built a custom iframe component locally and deployed it to the instance, correct? Or are you using the default iframe component in UIB to show the external content without any local development?
If you've built the custom component yourself you should theoretically have pretty full control over what it does, including communicating with an iframe. Unfortunately, I've not done that before in a custom component and don't have any examples for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2022 07:59 AM
Yes, I built a custom iframe component locally and deployed it to the instance. The "src" URL of the iframe element points to a web app in which I can run my own event-handling code. I just don't see how that code (from domain 1) could pass messages to my UIB custom component (running in domain 2) without using the postMessage API.