File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is there any way to capture window closing event in javascript
 
Similar Threads
Logout when exit
applet refresh event
Can logout be implemented?
Using onbeforeunload event of Javascript
j_security_logout issue