Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to detect Browser close

 
Ahmed M. Omar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to detect the event when the browser close BUT I NEED A PROFESSIONAL SOLUTION.

all of the solutions available on the internet (depending on client coordinates and on load and on unload) are fake


please i need a real solution to that problem
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There isn't a reliable way to know if a browser has closed.

Browsers crash, operating systems crash, network connections crash.
There are many situations where a browser will not be able to communicate a problem to the server.
Your server application should not rely on being able to tell if the user is still looking at your application.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best solution is to use the onbeforeunload event however, I suspect it won't work as you want it to. There isn't a great solution to this problem.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahmed M. Omar wrote:I need to detect the event when the browser close BUT I NEED A PROFESSIONAL SOLUTION.


There is not one. Session End on the server is your friend for a reason.

Eric
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heck, some of my "web browsing" doesn't involve a browser anymore; I'm not sure how much, but I know it's gone up quite a bit.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic