aspose file tools
The moose likes HTML, CSS and JavaScript and the fly likes Catching the browser close action Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
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: 108
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: 56201
    
  13

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Catching the browser close action
 
Similar Threads
Logout Code is not working
Closing browser
Delete Records When user clicks close button of a browser
logOut script not working
perform a specific task on logout/closing of browser