Javascript events like onbeforeunload, beforload, preventDefault are not working in retool

Hi @Tess /All,

Javascript events like onbeforeunload, beforload, preventDefault are not working in retool. Is it something that cannot be enabled or can we do that?

My requirement is to give an alert prompt to the user when trying to close the browser tab or window.

Can you please help here

Thanks!!

Hello @Jyothi!

Unfortunately those methods do not work with Retool :sweat:

They require access to the window and the DOM to understand when those events occur. However, Retool code/JS is executed in a sandbox for security purposes and this is why users are not able to use window or document.

This had been a feature request from another user who wanted the same functionality but this was closed because it seems that the sandbox executor is not able to allow javascript in Retool to interact with the browser.

Apologies for the inconvenience :smiling_face_with_tear: