473,508 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onunload

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...
Nov 19 '05 #1
1 3904
"Angel" <An***@discussions.microsoft.com> wrote in message
news:23**********************************@microsof t.com...
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
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
8544
by: Andoni | last post by:
Hi, I am only writing for IE 5.5+ so no need for compatibility at all ;-) I am trying to get my users to logoff which they finish on a particular page. This is no problem (or should be no...
2
5637
by: Simon Wigzell | last post by:
I'm using OnUnLoad in my body statement to redirect to a function to clean things up if someone exits a form by closing it from outside the webpage code - e.g. by not using the cancel or save and...
6
15880
by: kaeli | last post by:
Hey guys, This error occurs ONLY in Netscape 7.0. Not in 7.1. So, I think it's a bug. Buuuut... Has anyone had this problem or know of a fix? When attempting to have an onunload function...
3
6944
by: Laurent | last post by:
I am trying to use the onunload event to know when the user closes a popup by receiving a request on the web server. I have a main page from where the user opens a popup. What I want is when the...
3
3663
by: Andrew Poulos | last post by:
In a frameset I have this: window.onload = function() { frames.onunload = function() { alert('I'm going now'); } } when frames unloads I'm expecting the alert to be called but it never...
2
1634
by: Rich | last post by:
Is there any way to get the same effect that the body tag onUnload creates. I need a script that will be placed in the body of the html that will open a new window when the parent is closed. The...
1
1505
by: Tim Arview | last post by:
Hi, I'm trying to create an exit popup that doesn't require anything added to the body tag. In other words, I don't want to say <body onunload="foo">. I just want to have window.onunload="foo"...
0
11805
acoder
by: acoder | last post by:
Problem onload and onunload events do not fire when going back, forward or refreshing the page Browser Opera Example Any code using onload or onunload, e.g. window.onload = init; where...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7133
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5643
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
435
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.