How to capture browser close event when user click on x?

  • Thread starter Thread starter feng
  • Start date Start date
F

feng

Hi,

In our asp.net app, we need to capture the event when user
close the browser window by clicking on the "x" button.
But it doesn't seem to be as easy as it sound. Can someone
show me how to do this?

Thanks
 
feng said:
In our asp.net app, we need to capture the event when user
close the browser window by clicking on the "x" button.
But it doesn't seem to be as easy as it sound. Can someone
show me how to do this?

You have to hook the JS evente onunload - but its not 100% reliable in all
versions of IE.
 
Can you elaborate on what your overall business goal is here? OnOnload may
work for your needs, but trapping native Windows actions (E.g. clicking on
Window chrome) is not trivial.

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.
 
our web application uses a RPC connection to start a Unix
backend runtime environment, which takes a considerable
amount of resource. It is critical that we make sure that
if a user exit the application, the RPC will be killed as
soon as possible. We are currently relys on session_end
event handler to do this. But it doesn't seem to be
enough. Depending on the sessin time out setting, each
user may leave several runtime environments on the backend
waitting for clearing. This is very bad and we need to do
something better.

An ideal solution will be: when user click on the "x"
button on their browser, we capture the event and clear
the resource. The only problem becomes, how to capture the
event. I tried OnUnload, but it doesn't seem to be
reliable.

Any other ideas?

Thanks
 
Back
Top