0

I want to make a confirmation before user leaving the page. If he says ok then it would redirect to new page or cancel to leave. I tried to make it with onunload .

I tried beforeunload, It is working OK. But I can't put confirm/alert inside beforeunload .

$(window).on("beforeunload", function() {
    if (flag_change_index == true) {
        var msg = 'You are about to leave the page.  Continue?';
        return msg;  //Webkit
    }
});

Is it possible to display a custom message in the beforeunload popup?

So, I need to 1 solution instead of beforeunload. It would be even better if someone shows how to do it with jQuery? Thank you.

0 Answers0