Confirmation pop up when user leaves page vs closes browser/tab

168 Views Asked by At

currently when the user leaves the page I use the beforeunload event to show the default browser popup.

But I don't want this popup when the user navigates to another page or so on. I have a canDeactivate guard with a custom popup and a custom confirmation message to do that.

I want the default browser popup only when the user tries to close the browser/tab.

How can I do this?

2

There are 2 best solutions below

0
On

may you can use ngx-page-visibility, I am not sure if it will serve exactly your needs, check it first

0
On

Hi my friend try this it will help you for you open it