Skip to main content

Good day everyone!

I am just wondering if its possible to add an exit warning/message when the user close the lightbox popup? Majority of our pages are now using lightbox for the form/quiz and we just want to minimize accidental exit because forms will reset when they reopen.

Hoping that this is possible.

Thank you!

Anyone have a workaround for this?


Hey @MBismark this is a great question! I wanted to chime in from our end, you are correct that you would need to use a workaround/custom solution as there is no native Unbounce feature for this. It should technically be possible to set something like this up and a suggestion would be to use the beforeunload  JS event to detect when a user is about to leave the page/lightbox. You can then trigger whatever you want (like a warning message).

2 resources that might be helpful for this: https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event & https://dev.to/amersikira/top-3-ways-to-easily-detect-when-a-user-leaves-a-page-using-javascript-2ce4.

I hope that you are able to find a solution that works for you here and please keep us updated with your progress! 💪


Hey @MBismark this is a great question! I wanted to chime in from our end, you are correct that you would need to use a workaround/custom solution as there is no native Unbounce feature for this. It should technically be possible to set something like this up and a suggestion would be to use the beforeunload  JS event to detect when a user is about to leave the page/lightbox. You can then trigger whatever you want (like a warning message).

2 resources that might be helpful for this: https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event & https://dev.to/amersikira/top-3-ways-to-easily-detect-when-a-user-leaves-a-page-using-javascript-2ce4.

I hope that you are able to find a solution that works for you here and please keep us updated with your progress! 💪


Hi Michael, thank you for chiming in. I have been playing around with beforeunLoad JS event for some time now but to know avail. It’s just not triggering the warning message.

I will give this another try and post any progress here. Thanks again!


Reply