Hi,
I would like my pack to open a pop-up window but cannot figure out how to do it, as the “window” object is not recognized in Coda SDK.
Any idea how to do it?
I would like to do something like this:
const popup = window.open(“https://coda.io”, “_blank”, “width=600,height=400”);
popup.focus();
Hi @Elian_Faggion - Unfortunately it’s not possible for a Pack to open a window. You can learn more about how Packs run here:
All Pack code is run on the server, ensuring a consistent and secure environment.
Packs are run in a custom JavaScript execution environment created by Coda, compatible with the ES2022 standard. You can use all the modern JavaScript features, but browser- and Node-specific objects are not available (window
, fs
, etc).
Because of that they can’t open windows directly like you can in regular browser JavaScript code. The pattern that some Pack makers use is to have a Pack formula that returns a URL, and instruct the user to pass that into the OpenWindow()
formula to open it in a new window. Here’s an example of one of my personal Packs where I did that:
Thank you @Eric_Koleda for your very thorough reply !
That is a big limitation indeed !
The OpenWindow formula seems to always open the link in a new tab, which is not the desired behavior (I was looking for a pop-up action).
I guess that I will have to invent a different solution then !