• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is there any way to capture window closing event in javascript

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic