Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 16th, 2006, 11:03 AM
Authorized User
Join Date: Jun 2003
Location: Jewett City, CT, USA.
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default Determine method of closing browser

I have created a Flash application that contains its own close button. When the use clicks this button, it saves a few final values to a database through an ASP page. If, however, the student chooses to close the browser either by using Alt-F4 or its X button, I'm unable to save the necessary data. So here's my question...

Is there a way to determine which method the user is trying to use to close the browser and display a message if one of the other methods is used?


Reply With Quote
  #2 (permalink)  
Old August 24th, 2006, 10:23 AM
Friend of Wrox
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts


You can use the window object's onbeforeunload method to catch closures, but the problem is it also picks up on refresh too as it has to unload the page to reload it. Also, AFAIK there's no way to actually stop a window from closing once the user requests it. You could force the window to reopen but at the risk of losing any form data they may have inputted, but you could store this in cookies (if they have them enabled). There's questions all over google about this, but I've never seen anyone manage it. Surely you run the risk of annoying the crap outta your users though if they can't close their browser?


'sync' <cr>
The name specified is not recognized as an internal or external command, operable program or batch file.
Reply With Quote
  #3 (permalink)  
Old August 31st, 2006, 05:34 AM
Friend of Wrox
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919

Hii chrscote!!
how this will help you

function saveData()
 //capturing ALT + F4
 if (event.altKey==true && event.keyCode==0 )

  // alert("closed2")


//or we can use body(unload) method


Cheers :)

Cheers :)

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
closing browser prv299 ASP.NET 2.0 Professional 1 June 5th, 2008 09:15 AM
browser closing vamsivaila Pro Java 0 January 3rd, 2007 06:43 AM
Delete files on closing browser spacy ASP.NET 1.x and 2.0 Application Design 7 September 8th, 2004 04:24 PM
Closing browser using a Button MichaelTJ ASP.NET 1.0 and 1.1 Basics 3 December 18th, 2003 02:06 PM

All times are GMT -4. The time now is 11:14 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.