Detecting window.onunload, closing the browser, or going to different page.

J

Jason

I am creating a Comet/Ajax chatroom system. When people go to the page,
it will add them to the list of people in the room via window.onload.
When they leave, disconnect, go to another page, or close browser, I
need to remove them from the room.

I use window.onbeforeunload, but it seems it doesn't always fire. IE &
firefox will only unload sometimes - sometimes I think maybe its
caching the page, and not calling onbeforeunload (my guess)? It also
doesn't get fired when the user closes the browser. Anyhow, does anyone
know how to detect with accuracy whether someone left the page,
disconnected, or closed the browser? I can't seem to rely on
window.onbeforeunload...


- Jason
 
B

BinnyVA

I use window.onbeforeunload, but it seems it doesn't always fire. IE &
firefox will only unload sometimes - sometimes I think maybe its
caching the page, and not calling onbeforeunload (my guess)? It also
doesn't get fired when the user closes the browser. Anyhow, does anyone
know how to detect with accuracy whether someone left the page,
disconnected, or closed the browser? I can't seem to rely on
window.onbeforeunload...

What about window.onunload ?

Binny V A
http://www.openjs.com/ - JavaScript Opened
 

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,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top