Get reference to the window created by utils.openUrl()

  1. My goal: I need to be able to open a new window at some URL, and then send messages to it with newWindown.postMessage(...)
  2. 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.
  3. Steps I've taken to troubleshoot: Open window with utils.openUrl(). No useful reference to new window can be found
  4. Additional info: (Cloud or Self-hosted, Screenshots)

Hey @reToolCurious , welcome to the forum! :wave:

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?

1 Like

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:
:link: 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:
:bookmark_tabs: 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!