1

Is there any way that i can override onbeforeunload popup ?

I tried with below but it does't work:

if($('body').hasClass('admin')){
    window.onbeforeunload = function(event) {
        notifySaveChangesUser(event);   
        //return null;
        //event.returnValue = "Say";
    };
}

function notifySaveChangesUser(event){
    //Doing some stuff here
}

1 Answers1

0

This question has been already answered here.

TL;DR: You can customize message by returning the desired string from the handler:

window.onbeforeunload = function() {
    return "You have some unsaved changes";
};

See the answer above for more details and browser quirks.

Community
  • 1
  • 1
Wiktor Czajkowski
  • 1,623
  • 1
  • 14
  • 20
  • I don't want to default popup. I am using apprise popup. I need to show that instead of default popup. Please let me know if you have any idea ? – Thirupathi Jarajapu May 16 '17 at 05:22
  • Well, as far as I know, the support for custom popups has been removed in recent versions of all modern browsers. I think it is ok to use the default one, as many big players, like GitHub or Google use it and are doing fine. – Wiktor Czajkowski May 16 '17 at 09:04