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

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
 
C

Chad Z. Hower aka Kudzu

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.
 
E

Eric Lawrence [MSFT]

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.
 
F

feng

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top