onunload

G

Guest

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...

thanks in advance...
 
J

John

Angel said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top