3
Answers

Restrict onbeforeunload event from being fired

Rakesh Dabde

Rakesh Dabde

9y
2.2k
1

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)