aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Browser X Button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Browser X Button" Watch "Browser X Button" New topic
Author

Browser X Button

Prasad Babu
Ranch Hand

Joined: Jul 17, 2005
Posts: 57
Hi,

I want to submit the form in a page when the user press the Browser window 'X' Button.(only press the 'X' button). of course some events like onunload useful but these events are called eac time when not even pressing the X button. i.e. from other source.

Any idea?

Thanks in advance,
Prasad
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
The onunload and onbeforeunload are called for anything that causes the browser to leave its current state. Basically there is no easy solution to solving the problem.

Eric
Prasad Babu
Ranch Hand

Joined: Jul 17, 2005
Posts: 57
Hi Eric,

Thanks for the reply. In my scenario,

One popup window will be opened to edit a form contains some fields to be persisted. in that window I ahve two buttons, one for 'update' and other for 'cancel'. whenever the user press the either buttons there is no problem as Database transactions are maintained and window will be closed. But when the user close the popup by pressing X button of the window(it is usual practice in windows environment. we cannot force the user to use buttons only), the database is locked as there will no action perform to release database lock.

Any idea?

Thanks in advance,
Prasad
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Look into modal window. You could set up the onbeforeunload. Look at this: http://www.eggheadcafe.com/articles/20010406.asp

Eric
Prasad Babu
Ranch Hand

Joined: Jul 17, 2005
Posts: 57
Hi Eric,

Thank you for reply. Really very nice idea. Its working fine in my case.

Thanks a lot.

With regards,
Prasad
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Browser X Button
 
Similar Threads
New Browser Window
measuring a line drawn
TRacking event.returnValue in IE
Application Not signing out Authenticate customers
TEXTFIELDS TO INT