Set up window eventListener to listen for page unload

Hi, I'm trying to set up a general window event listener, specifically, the 'before unload' event from the page lifecycle API.

Question: Is there any way to set general listeners in a retool dashboard -- setting JS that isn't triggered by a UI action or on pageLoad.

My use case is just generating a warning modal if the user exits their tab or browser.

Thank you!

P.S. Hi Victoria / best TA ever!!! :smiley:

Hello mysterious @alw93!

We don't have access to window event handlers, like onbeforeunload, since all JS in Retool runs in a sandbox. 😓

1 Like

oof, okay will have to think of another solution then :slight_smile: ty!