jQuery in Action, 2nd edition*
The moose likes HTML, CSS and JavaScript and the fly likes Is there any way to capture window closing event in javascript 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 "Is there any way to capture window closing event in javascript" Watch "Is there any way to capture window closing event in javascript" New topic
Author

Is there any way to capture window closing event in javascript

Ashish Agr
Greenhorn

Joined: May 13, 2011
Posts: 6
Hi,

I was searching how to capture the window closing event in java script. Is there any way out in java script, if not through any other technology for jsp pages.

I need to update the save the logout details of the user when the window is closed instead of user doing logout.


Thanks,
Ashish
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
https://developer.mozilla.org/en/DOM/window.onbeforeunload

but it is fired for page refreshes, navigating to other pages, and closing. No way to tell the difference.

Also what happens when people put computer to sleep, have no internet connection all of the sudden, browser crashes, etc. That event would never fire.

Only way to really do it is with session end on the server.
 
 
subject: Is there any way to capture window closing event in javascript
 
Similar Threads
Using onbeforeunload event of Javascript
j_security_logout issue
Can logout be implemented?
Logout when exit
applet refresh event