Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > server needs to know when user closes browser window

Reply
Thread Tools

server needs to know when user closes browser window

 
 
feng
Guest
Posts: n/a
 
      12-03-2003
Hi,

When user closes a browser window by clicking on the "X"
button, I want the server to be noticed (either through
postback or calling other ASP pages, etc.) and perform
some task accordingly. Please note that I can't use
session end event, since the session is still alive now
and the user is just closing a secondary window he/she
opened.

I tried to use the <BODY> tag's onunload client side event
and put a flag in a hidden textbox then submit the form
(post back). But this didn't work for me -- my code on the
server side can't really capture the event properly.

What's the proper way of doing this? Can anyone help me?

Thanks
 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      12-03-2003
OnUnload is an option, but you have to have a method of speaking to the
server. Perhaps having the code navigate to another page that says "are you
sure you want to close this window" and having that page tell you they are
closing the window. But, that might tick off users.

The difficulty here is HTTP is stateless, which means the client is
disconnected once they have recieved a page. In an Intranet environment, you
have more options, of course.

If you can set up the popup window so there is no header bar (thus no X to
close) and put a "Close window" button, you have the ability to handle the
event on the server side, but this may end up causing a dialog stating
"someone is trying to close this window" or similar.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"feng" <(E-Mail Removed)> wrote in message
news:073501c3b9b9$67831cc0$(E-Mail Removed)...
> Hi,
>
> When user closes a browser window by clicking on the "X"
> button, I want the server to be noticed (either through
> postback or calling other ASP pages, etc.) and perform
> some task accordingly. Please note that I can't use
> session end event, since the session is still alive now
> and the user is just closing a secondary window he/she
> opened.
>
> I tried to use the <BODY> tag's onunload client side event
> and put a flag in a hidden textbox then submit the form
> (post back). But this didn't work for me -- my code on the
> server side can't really capture the event properly.
>
> What's the proper way of doing this? Can anyone help me?
>
> Thanks



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
By closing a window in firefox browser closes all other windows karthi Javascript 0 01-31-2006 05:38 AM
How to detect that user closes the user-agent window ? Luke Matuszewski Javascript 8 12-02-2005 10:20 PM
Cancelling session when user closes browser window... Charlie@NISH ASP .Net 3 08-30-2005 08:00 PM
Results from child window submit into parent window, then child closes -- How To? Spammay Blockay Javascript 1 02-04-2005 12:47 PM
Trapping the <BODY> onUnload() / Detecting when a user closes the browser =B= ASP .Net 3 09-30-2004 08:20 AM



Advertisments