vali66
asked on
Raising Javascript funtion on clicking of X button of Web form
I am working with web forms
ASP.Net 2.0+C#.Net
I am opening a modal dialog window from a parent page.Now when the user closes the modal dialog window by clicking on X button I want to raise a javascript function.How do I do that.I dont want to use onunload event of form...any other way?
ASP.Net 2.0+C#.Net
I am opening a modal dialog window from a parent page.Now when the user closes the modal dialog window by clicking on X button I want to raise a javascript function.How do I do that.I dont want to use onunload event of form...any other way?
ASKER
The modal dialog window I am using is basically used for progress bar functionality.So this form will get loaded and unloaded at each instance and obviosly I cant use onbeforeunload and onunload.
So Is there any other way of raising javascript function when the user clicks on X button??
So Is there any other way of raising javascript function when the user clicks on X button??
as per my knowlede No other way is available
Hello vali66,
You could use one of the before mentioned events like a dead-men-switch.
Attach your event handler code to handle "unexpected" closure of the window. When the progress bar completes normally, flag this, so the close handler will not run.
You could use one of the before mentioned events like a dead-men-switch.
Attach your event handler code to handle "unexpected" closure of the window. When the progress bar completes normally, flag this, so the close handler will not run.
<BODY onunload="Body_OnClose()">
<script language="javascript">
<!--
var noramlClose = false;
function Body_OnClose()
{
if (normalClose)
return;
alert("Unexpected closing");
}
//-->
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<BODY onbeforeunload="HandleOnCl
Then, add the following JavaScript code into the <HEAD> section of your ASPX page:
<script language="javascript">
<!--
function HandleOnClose() {
if (event.clientY < 0) {
event.returnValue = 'Are you sure you want to leave the page?';
}
}
//-->
</script>