473,503 Members | 1,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Detecting user closing window X

Hi all,

Can anybody let me know how to detect when my user clicks the X button
on the window. I used unload event it did not work(on IE). My web page
is a .asp page which reloads itself when navigating on the site. Now
whenever the user clicks any links on the page the unload event is
triggered which is not what I want. I only want to detect when user
clicks the X button and not when the URL changes.

code i used:
<body onunload="alert('leaving window');">

Basically this alert window is triggered everytime the URL changes and
not just when the window closes(which is what i want).
Appreciate your reply.
Kiran

Jul 23 '05 #1
2 2082
Kiran wrote:
Hi all,

Can anybody let me know how to detect when my user clicks the X button
on the window.


You can't.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #2
Kiran wrote:
Hi all,

Can anybody let me know how to detect when my user clicks the X button
on the window.

[...]

The web is "stateless". You never know whether you users are still
there or not. Don't try to detect if they are still looking at your
page, design your system so it isn't necessary. There is no reliable
way of knowing whether they are or not.

There are lots of ways of closing a window such that the browser never
gets to know it's about to be killed (Windows task manager, UNIX
kill -9, Mac "force quit application" do dad, turn off power, etc.).

Nothing for it but to learn to live with it. :-)
--
Fred
Jul 23 '05 #3

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

Similar topics

0
2720
by: Erik Bethke | last post by:
Hello All, I am trying to clean up some polish bugs with the Shanghai game I am working on and I am currently stuck on trying to get the right event for detecting when the user has changed the...
1
2847
by: Erik Bethke | last post by:
Hello All, I am trying to clean up some polish bugs with the Shanghai game I am working on and I am currently stuck on trying to get the right event for detecting when the user has changed the...
2
2091
by: G | last post by:
Hello, I want to launch a pop-under survey when a user leaves my page by closing the window, but NOT by leaving the page via a hyperlink or form submission. Is this easy to accomplish with...
10
4094
by: Frances Del Rio | last post by:
pls, why is this not working? <SCRIPT language=JavaScript type="text/javascript"> var br = '<SCRIPT language=Javascript' br += 'src="js_pop.js" type="text/javascript">' br += '</SCRIPT>' var...
2
2304
by: Paul Steele | last post by:
Some time ago I tracked down the code for detecting the shutdown event within a C# program. I tested it, it worked, and I moved on. However, I just discovered that the code is no longer working,...
3
5864
by: =B= | last post by:
Hi all, I was wondering if anyone has had any luck with trapping the <BODY> onUnload() event in ASP.NET? The thing is, I'm writing code for an Intranet site. The code makes a call to a...
1
5556
by: Tuong | last post by:
I have a situation where i have a form that contains a webbrowser control. With this I was able to implement an application that can browse websites. One particular website i visited opens up...
79
3705
by: VK | last post by:
I wandering about the common proctice of some UA's producers to spoof the UA string to pretend to be another browser (most often IE). Shouldn't it be considered as a trademark violation of the...
1
3037
by: Jason | last post by:
I am creating a Comet/Ajax chatroom system. When people go to the page, it will add them to the list of people in the room via window.onload. When they leave, disconnect, go to another page, or...
0
7084
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
7278
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
7328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5578
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,...
1
5013
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3167
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
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.