0

I have the below event in one of the angular controllers. I get a prompt with 2 options "leave this page" or "stay on this page" when it hits the below beforeunload event. Is it possible to not to display the options at all and just silently prevent the refresh? Thank you for any suggestions.

var windowElement = angular.element($window);
        windowElement.on('beforeunload', function (event) {
            event.preventDefault();
            event.stopPropagation();
        });
Jyina
  • 2,530
  • 9
  • 42
  • 80
  • 2
    No, it is not possible.... – epascarello Mar 14 '19 at 18:20
  • 1
    See https://stackoverflow.com/a/3527055/4505310 – Jimmy Leahy Mar 14 '19 at 18:25
  • 1
    Personally I don't think you really want this behavior, users are accustomed to certain features irrespective of applications provided by browsers. Interrupting these with your own application is wrong and shares a similar feel to those annoying popup pages that prevent navigation away, if your user wants to refresh they should understand that they will lose content on the page as a result (the only exception being to at least warn them with the system you already have). – Craig Oldfield Mar 14 '19 at 21:03

0 Answers0