Rakesh Dabde

Rakesh Dabde

  • NA
  • 453
  • 71.9k

Restrict onbeforeunload event from being fired

Aug 13 2013 8:22 AM

I am using Ajax tabcontainer. i want to restrict the onbeforeunload event being fired on Ajax TabContainer. On click of one of the tab of TabContainer i am getting the alert/confirm message box which i have return in Onbeforeunload function.

The alert occurs because on tab click i have written C# code so postback occurs.

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

});

window.onbeforeunload = function() {
                return 'Pending changes will be lost unless they are saved first.'
                'Are you sure you want to leave this page?';
            };
Thanks in advance

Answers (3)