Re: onunload



"Angel" <Angel@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:23C9D2E1-188D-4F8F-800D-B5C117ED4FB3@xxxxxxxxxxxxxxxx
>I am trying to capture when the user clicks the X button on the ie window.
>I
> have used the onunload for the window event, but there is a problem. I put
> javascript code for this event and when the form performs a postback on
> the
> page, the onunload event gets triggered eventhough I am still on the same
> page and the user did not click the 'X' button. In other words, the
> onunload
> event is triggered when you are performing a postback to the page. Is
> there
> anyway around this? I want to capture when the user clicks the 'X' and not
> when the page is performing a postback...
>

If you are only using this for the X button, why not put the script in the X
buttons onclick event?

If you need if for other times, leave the functionality in the unload event,
and set a flag in the X button onclick event.

Also, be aware that if the form has validation and validation fails, you may
still be looking at a problem. I have managed to overcome the clientside
validation of the asp.net validation controls by using the following in the
onclick event :

if("none" != valSummary.style.display)
{
// perform my unload functionality.
}

Good luck,
John MacIntyre
http://www.johnmacintyre.ca
Specializing in; Database, Web-Applications, and Windows Software


.


Loading