I'd like to display a "Do you want to leave this site?" alert

I am creating a user information form page.
I want to prevent users from accidentally deleting tabs or reloading the page while typing.
I'd like to display a "Do you want to leave this site?" alert that can be implemented with a "beforeunload" event trigger.
Is it possible to do something like this with retool?
Any method is fine as long as you can do something similar.

thanks for reading the question.


I am not familiar with any Retool way to do this. But I do know there is a general browser way to do this as I have seen it done, though never done it myself.

I have no specific advice other than get your Google-fu on. Hopefully there is some JS that does it and Retool's sandbox does not defeat it.

You will also need to track if your data is "dirty" (changes but unsaved) so you know when it is appropriate to alert the user. Search this forum for some ways others have solved this.


As you said, I'll try another way to prevent it. Thank you.

I'm also unaware of a way to do this within Retool though others may indeed have found ways to do it!

It has been brought up as a request before, I'm going to move this into the feature request section for now and we can let you know here if more support gets added :slightly_smiling_face:


+1 I'd also like a way to achieve this

1 Like

+1 on this

1 Like

+1 on this

+1 on this