473,326 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Why won't windows.close() in function close the window?

103 100+
I am learning java script watching tutorials and have created this simple code. The function executes 50%. When I click the button to close the window, the window.confirm appears and when I click okay, the window.close() should execute and close the window. The window does not close. Any suggestions or comments would be greatly appreciated. The simple code is below.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <title>Pop-up Ad Example</title>
  3.     <head>
  4.         <Script language="javascript">
  5.             function closeWindow(form){
  6.             window.confirm("Are you sure you want to close this page?");
  7.  
  8.             window.close();
  9.         }
  10.         </script>
  11.     </head>
  12. <body>
  13.  
  14.         <form name="myform">
  15.             <input type="button" name="button" value="Close this Window" onClick="closeWindow(this.form)"></br>
  16.         </form>
  17. </body>
  18. </html>
  19.  
Jan 7 '12 #1
1 1934
Dormilich
8,658 Expert Mod 8TB
window.close() only works on windows you have previously opened with window.open().
Jan 7 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: jrefactors | last post by:
>From the main page, there are lots of links to open new window. i.e. <a href="#" onClick="window.open('child1.html')">Open Child Window</a> If I close the main page, I want to close all child...
2
by: Irvin Amoraal | last post by:
Process: I have a form which uploads a file from client to server written in PHP. When the user presses the submit button, I use the "onSubmit" event to execute javascript to open a child window...
6
by: marcelf3 | last post by:
Hello.. This page opens a window with some information, but everytime the user changes a field in the parent window, the child window needs to be closed. These 2 functions were supposed to do the...
6
by: Sujan | last post by:
Hello all, Help me! -------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <script language="JavaScript"> <!--
10
by: morangolds | last post by:
Hi, I've been having a problem with C++ Windows Forms apps not "ending" when you close the form window. I've searched about this problem all over the place and most searches have lead me to...
1
by: Chinna10 | last post by:
Hi, I want close sub windows when i log out from main window or close the main window. I need to write the code in pop up window. That pop up has been in ore than 2 parent windows. how to...
7
by: manojuniverse | last post by:
Hi I have open a window using javascript function window.open() like <script language="javascript"> { function open1() { window.open("one.aspx");
1
by: dittu | last post by:
How to close the popup window when submitting the form? I have a sample.jsp. In that page one button is there. when button pressed, open popup window contains one "text box" and one " submit...
2
by: rkyakkala | last post by:
Hi, i am creating a popupwindow example.After entering the details i want to close the parent window(details.html)as it is moving to new window.could anybody suggest how can i do both task at a time...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.