Is there a way to use the beforeunload event before closing the popup?
Application Type
Traditional Web

Hello all

  • Is there a way to use the beforeunload event before closing the popup?
  • I want the User to ask if I want to close the popup
  • For that purpose, the following JavaScript is created.
  • window.addEventListener('beforeunload', (event) => {
      event.preventDefault();
      event.returnValue = '';
    });
  • However, even if you press Cancel in the dialog that appears when you close the popup, the popup will close.
  • Is there a way around this?







Hi 

You can use modal preview for such states ,also you can find my attached OML for same type of Question 

https://www.outsystems.com/forums/discussion/69044/how-to-display-a-dialog-box-when-i-close-the-popup/#Post277459?utm_source=community&utm_medium=email&utm_campaign=forum-reply

Regards,

Komal

Hi

Komal

Thank you

It was helpful

You're welcome , I am happy that it helped.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.