Link to home
Start Free TrialLog in
Avatar of rakhras
rakhras

asked on

Detecting when browser exits

Hi,

I'm writing an ASP application that is accessing
a database. I need to be notified when a user closes the
browser (Netscape or IE) and write something to the database
when the browser is closed.

Additionally, I was trying to find a way to be notified when
a Session times out (a Session as defined by ASP).

Any ideas?
Thanks,
Ralph

ASKER CERTIFIED SOLUTION
Avatar of quekky
quekky

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rakhras
rakhras

ASKER

quekky,

That sounds good. However, the unload event is also triggered
when the Refresh or Reload buttons are pressed.
Do you know if there is any way of trapping when the
user presses the Refresh/Reload button?

Thanks,
Ralph
if u are do programming in java, maybe u can do that
else i do not know of any way for the reload button
the other way is to wait for the session timeout
Avatar of rakhras

ASKER

quekky,

yes, i'm programming in java. How would you do it in Java?
Avatar of rakhras

ASKER

quekky, actually i mean i'm programming in java script.

oh, sorry, even in java if u press reload the exit event will also be called
i think u use the session timeout and maybe the javascript i gave u
Avatar of rakhras

ASKER

quekky,

The issue with using the Session timeout events is that they are not called when you close the browser. They will eventually be called when the session expires but that's too late.

ralph
oic, u have to use the javascript but your asp code need to detect if u press reload or close the browser
maybe on your main asp page u set a var1=1
in your exitbrowser asp page u set var1=0 then wait 30 secs and if var1 still =0 then the browser is really closed
just a suggestion, u can try it out