• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it possible to execute a function on window close

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34229
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not reliably. You shouldn't do this. What are you trying to accomplish? Maybe there is another solution?
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 34229
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use AJAX to send the data to the server as soon as it is changed.
 
Romit Bose
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jaenne ,

Eric ,Bose,
Not acceptable solution , but thanks for knowledge Transfer.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no solution for this...

Eric
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic