This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Javascript function" Watch "Javascript function" New topic
Author

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.

Thanks.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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.

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Javascript function
 
Similar Threads
How to stop browser window closing
disable javascript for browser
Can I have Controlled Prinitng in JavaScript
which event will fires before closing the browser window
New Window