aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes how to invoke a function in javascript on closing the browser window 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 "how to invoke a function in javascript on closing the browser window" Watch "how to invoke a function in javascript on closing the browser window" New topic
Author

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

Anand Sivathanu
Ranch Hand

Joined: Jun 25, 2010
Posts: 76
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

Joined: Jan 10, 2002
Posts: 61653
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to invoke a function in javascript on closing the browser window