0

I tried the following code to get an alert upon closing a browser window:

 <script language="JavaScript" type="text/javascript">
    window.onbeforeunload = confirmExit;
    function confirmExit()
{
    return "Please log out before exit";
}
   </script>

It works, but if the page contains few button, clicking on that any button raises the same alert. I need to show the alert only when I close the browser window and not upon clicking button.

wksl
  • 5
  • 6

1 Answers1

0

Use this

$(function () {
  $("a").click(function {
    window.onbeforeunload = null;
  });
});
parveen
  • 557
  • 3
  • 13