0

Okay, I have a live application, it runs a messenger and I am trying to find the most reliable way to determine if a user has navigated away from the page or closed the window, et cetera. I have already implemented this:

window.onbeforeunload = function(event){ /* my code */ };

But that isn't always very reliable, sometimes it will fire and sometimes not. Is there a more reliable way of determining user presence or lack thereof?

nkcmr
  • 10,690
  • 25
  • 63
  • 84

1 Answers1

2

Have the browser ping the server every X minutes. If you're making a chat client you'll likely have all the infrastructure you need already.

Halcyon
  • 57,230
  • 10
  • 89
  • 128