Kanwar Singh
Kanwar Singh

Reputation: 908

How to pop up message on closing web browser

I need to find browser close button click event in my web application. I need to show some alert message on that event. I tried to do it using window.onbeforeunload event, but it gets called on every page navigation or page refresh I need to execute that function only on close button click event

Upvotes: 1

Views: 1953

Answers (1)

Amit
Amit

Reputation: 2565

$(function () {
  $("a").click(function {
    window.onbeforeunload = null;
  });
});

see here

Upvotes: 2

Related Questions