on the internet you will find many people suggesting using something like
window.onbeforeunload = null
but this does not work for me in IE6. reading in the MSDN docs for the event object, I found a link to the event.cancelBubble property, which I thought was the solution. but thanks to Orso, who pointed out that setting "event.cancelBubble = true" is useless, the way to get rid of the confirmation request is to completely exclude the return statement, I decided to use a boolean variable as a flag to decide whether to return something or not. in the example below, I am adding javascript programtic code in the code behind:
Page.ClientScript.RegisterStartupScript(typeof(String), "ConfirmClose", @" <script> window.onbeforeunload = confirmExit; function confirmExit() { if(postback == false) return ""Please don't leave this page without clicking the 'Save Changes' or 'Discard Changes' buttons.""; } </script>");
then the help button contains the following aspx markup:
OnClientClick="postback=true;return true;
this sets the postbackback variable to true, which receives the confirmExit () function, which has the effect of canceling the event.
hope you find this helpful. It is tested and works in IE6 and FF 1.5.0.2.
Jake
source share