468,738 Members | 1,753 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,738 developers. It's quick & easy.

How to detect IE window close (X) action by user?



Kumar.A.P.P
Software Engineer, Infosys Technologies Limited.
http://techaid.wordpress.com/
Oct 16 '07 #1
5 2344
"Kumar.A.P.P" <Ku******@discussions.microsoft.comwrote in message
news:86**********************************@microsof t.com...
This question comes up time and time again.

Generally speaking, there is no way for the server to know if the client
browser has been closed, or even if the client has navigated to another
website.

This is because of the fundamental architecture of the web.

The server waits for an incoming HttpRequest.

The server processes the incoming HttpRequest.

The server sends back an HttpResponse.

The server waits for an incoming HttpRequest. If no incoming HttpRequest
arrives, there's nothing the server can do about it...

There have been various possible solutions suggested, mainly to do with the
<body onloadmethod, but none is satisfactory...

Why do you need to know this anyway...?
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 16 '07 #2
in javascript catch the onbeforeunload or onunload event, and check the
event x & y positions (they will be off srceen). its a hack.

-- bruce (sqlwork.com)
Kumar.A.P.P wrote:
>
Kumar.A.P.P
Software Engineer, Infosys Technologies Limited.
http://techaid.wordpress.com/
Oct 16 '07 #3
As above, catch the body.unload event and fire a postback event from
Javascript to tell the server the page is closing.

The only draw back is that is will fire when the user closes the
browser and when they move to a different page.
Fran

http://www.bluejumper.com

Oct 17 '07 #4
"BlueJumper.com" <fr*******@gmail.comwrote in message
news:11**********************@i13g2000prf.googlegr oups.com...
As above, catch the body.unload event and fire a postback event from
Javascript to tell the server the page is closing.

The only draw back is that is will fire when the user closes the
browser and when they move to a different page.
That's right - so not much use for any website which has more than one
page...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 17 '07 #5
On Oct 17, 9:52 am, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:
"BlueJumper.com" <fran.h...@gmail.comwrote in message

news:11**********************@i13g2000prf.googlegr oups.com...
As above, catch the body.unload event and fire a postback event from
Javascript to tell the server the page is closing.
The only draw back is that is will fire when the user closes the
browser and when they move to a different page.

That's right - so not much use for any website which has more than one
page...

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net

As you so eloquently pointed out, it depends why you need to do this!

Oct 17 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by RonS | last post: by
2 posts views Thread by Jawahar Rajan | last post: by
18 posts views Thread by Roger Withnell | last post: by
5 posts views Thread by Hemanth | last post: by
3 posts views Thread by Lord2702 | last post: by
8 posts views Thread by Luke Matuszewski | last post: by
5 posts views Thread by lindanr | last post: by
37 posts views Thread by Jan Tovgaard | last post: by
reply views Thread by zhoujie | last post: by
xarzu
2 posts views Thread by xarzu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.