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
Register
| 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 10th, 2005, 02:00 PM
Authorized User
 
Join Date: Jun 2003
Location: Jewett City, CT, USA.
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default Determining how a window is closed

I have a Flash application which I'm displaying in a popup. This application has its own close button to be used so that I can save some data to a database and I want to make sure that the users only use this button to close the app. I now have an onBeforeUnload action in the application window, but if the user uses the correct Flash close button, I still get the message. Is there a way to only display the message if the Windows X button or Alt-F4 is used to close the window?

Chris

Reply With Quote
  #2 (permalink)  
Old June 15th, 2005, 08:39 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
Default

Hi Chris
Try this

<script>

function closeWindow()
{
 //capturing ALT + F4
 if (event.altKey==true && event.keyCode==0 )
{
  alert("closed1")
   window.close();
  }

Xwidth=window.document.body.offsetWidth-window.event.clientX
YHeight=window.event.clientY
if(Xwidth<=30&&YHeight<0)
{
  alert("closed2")
    window.close();

}

}
window.onbeforeunload=closeWindow
//or we can use it on body tag with (unload) method

</script>

Hope this will help you


Cheers :)

vinod
Reply With Quote
  #3 (permalink)  
Old June 16th, 2005, 07:53 AM
Authorized User
 
Join Date: Jun 2003
Location: Jewett City, CT, USA.
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That works perfectly. Thank you so much for the help!!!

Chris
Reply With Quote
Reply


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 all child window when browser is closed h@ckerz ASP.NET 2.0 Professional 1 July 17th, 2008 01:04 AM
closed parent window when opened child window jaiwin Javascript How-To 0 October 8th, 2006 12:54 PM
how to destroy session when window is closed chayanvinayak PHP How-To 1 June 1st, 2006 06:18 AM
Determining if form is closed Paula222 Access VBA 2 April 17th, 2006 02:09 AM
return previous file after a window is closed hosefo81 PHP How-To 2 January 1st, 2004 02:13 AM



All times are GMT -4. The time now is 07:48 AM.


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