File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Javascript function 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 "Javascript function" Watch "Javascript function" New topic

Javascript function

Mark Butcher
Ranch Hand

Joined: Jun 28, 2012
Posts: 46
Hi everybody,

I want to invoke a javascript function just before a browser window is closed.
That means, if the user manually closes the browser window,
then that function should be called just before closing that window.
I tried html body "onunload" to call the function, but not working.

Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
There is no real way of knowing if the person closes the window, refreshed the window, or navigates to a new page.

If you are trying to clean up a session on the server, that is what the session end events is for.

I agree. Here's the link:
subject: Javascript function
It's not a secret anymore!