aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Is it possible to execute a function on window close 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 "Is it possible to execute a function on window close" Watch "Is it possible to execute a function on window close" New topic
Author

Is it possible to execute a function on window close

RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528

Hi Experts ,

Is it possible to call a function if the user directly closes the browser (I mean through cross mark on top of the browser).

Waiting for your responses.


If you want something you never had do something which you had never done
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31079
    
163

Not reliably. You shouldn't do this. What are you trying to accomplish? Maybe there is another solution?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528

I want to run a function that is responsible for saving the modified data on to changes made on a Text Fields.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31079
    
163

You could use AJAX to send the data to the server as soon as it is changed.
Romit Bose
Ranch Hand

Joined: Oct 03, 2007
Posts: 50
Hi,
May i dare say that if it is absolutely nessecary to run the function at window close, you could fight with (read, convince)the client and get a permission to disable the X on the browser window. No, I am not kidding, coz this happend in one of our projects and we actually did that... we provided one close button on the page.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
The only way to not show the X on a browser is to run it in kiosk mode, which is not feasible in 99.9% of the applications out there.

The only events you have to work with are onload and onbeforeunload.

Eric
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Thanks Jaenne ,

Eric ,Bose,
Not acceptable solution , but thanks for knowledge Transfer.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
There is no solution for this...

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it possible to execute a function on window close