GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes Catching the browser close action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply locked New topic
Author

Catching the browser close action

Fawad Ali
Ranch Hand

Joined: Dec 28, 2009
Posts: 112
Hi All,
I want to catch the browser close button action. Let me explain the scenario first. When a user clicks on the close button of a browser, I want to send an ajax call to set his loginStatus to false in the database. I can do it with the js event of onbeforeunload, but that has too many problems. The biggest being, when I navigate to some other site say google.com, it will set the login status to false, but then when I click on the back button, the session should remain there (ideally), but its logged out.

Any ideas on how to hunt for the solution?


Regards, Fawad Ali.
Software Engineer, Stafona Inc. - My Blog
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61314
    
  66

This has been discussed dozen and dozens of times. Please search for previous discussions. The bottom line is that there is no way to determine when the browser has been closed.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
GeeCON Prague 2014
 
subject: Catching the browser close action