wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes how to detect Browser close Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to detect Browser close" Watch "how to detect Browser close" New topic
Author

how to detect Browser close

Ahmed M. Omar
Ranch Hand

Joined: Mar 02, 2010
Posts: 43
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

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.


GenRocket - Experts at Building Test Data
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Sep 29, 2008
Posts: 12617

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.
 
 
subject: how to detect Browser close
 
Similar Threads
Stopping a backend process if user closes the browser window
Capture browser close
Problem with IE7
Software to detect if cookies are blocked
How to detect browser close in firefox?