- My goal: I need to be able to open a new window at some URL, and then send messages to it with newWindown.postMessage(...)
- Issue: There does not appear to be a way to get a reference to the window opened with utils.openUrl(). Opening a window in the Preloaded JS does not work because it is blocked due to sandboxing permission issues.
- Steps I've taken to troubleshoot: Open window with utils.openUrl(). No useful reference to new window can be found
- Additional info: (Cloud or Self-hosted, Screenshots)
Hey @reToolCurious , welcome to the forum!
If you want to open a new window in Retool, you can use the utils.openUrl()
function with the newTab: true
option. This will open the given URL in a new browser tab, which works like opening a new window in the Retool app environment.
Screenshot:
util.openUrl() does not provide a reference to the opened window. I mentioned in my original post that the goal is to be able to call the postMessage() method on the newly opened window. Is there some way to open a new window in retool and get a reference to it?
Hey @reToolCurious,
You're right that util.openUrl()
doesn't return a reference to the newly opened window, so calling postMessage()
on it directly isn't possible using that method.
However, you might find this Retool Community post helpfulβit dives into strategies for messaging between windows when embedding Retool apps:
Community Post β Embedding Retool & Messaging to Parent
Also, here's the official Retool documentation on embedding apps and passing data between parent and child contexts:
Retool Docs β Embed Apps
These resources should give you a clearer direction on implementing communication between windows in Retool. Let me know if you need help with a workaround or a custom approach!