• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to invoke a function in javascript on closing the browser window

 
Anand Sivathanu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I would like to know to invoke a function in JavaScript on closing the browser window.I am trying to

invalidate the user's session in JSP when the user unfortunately closes the browser window.

I have tried the following steps

function UnLoad() {
window.alert("on closing");

}

window.onunload=unLoad;

<body onUnload='javascript:UnLoad();'>


but its not working.

Please help me in this issue.

Regards,
Anand Sivathanu
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65217
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has been discussed many many times before in this forum. Please SearchFirst.

The result is always the same: you cannot be reliably informed when the browser is closed. You must rely upon the session timeout to allow orphaned sessions to be reclaimed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic