• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is there any way to capture window closing event in javascript

 
Ashish Agr
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic