I need a 'verify save' pop-up message using the onbeforeunload event (when the user closes the window or clicks the link that “leaves” the Angular application page).
This works fine, but I realized that when I get a 302 redirect, the event also fires.
Now I understand that I am before the page is unloaded, but I do not want it to start when the page is redirected.
How to detect event redirection?
$window.onbeforeunload = function (event) {
return "If you leave the page now your changes won't be saved.";
}
source
share