#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Nov 2004
    Posts
    3
    Rep Power
    0

    Javascript close all windows


    How can I close two windows with one click, I've got a pop-up navigation, and I want a "Close Window" in that pop-up that will close it, AND the main page that it is loading the content into.
    This is the code for my pop-up:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html 
    	 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    	 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>Geldart, Laura - 100238543 - Assignment 4 (Working with Windows) - JAVA2301</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    <script language="Javascript" type="text/javascript">
    <!--
    contentArray = new Array("","page1.html","page2.html");
    function updateParent(thisPage) {
    opener.document.location.  href = 
    contentArray[thisPage];
    }
    function confirm() {
    var check = confirm('Close all windows?');
    if (check) {
    window.close();
    }
    else {
    return false;
    }
    }
    function closeAll() {
    if (updateParent && !updateParent.closed) {
    updateParent.close();
    window.close();
    }
    else {
    window.close();
    }
    }
    -->
    </script>
    </head>
    <body bgcolor="#ff88bb" onbeforeunload="confirm()">
    <p class="pageTitle">Control Panel</p>
    <p class="navText"><a href="javascript: updateParent(1)">Load Page 1</a></p>
    <p class="navText"><a href="javascript: updateParent(2)">Load Page 2</a></p>
    <p class="navText"><a href="javascript: closeAll()">Close Windows</a></p>
    </body>
    </html>
  2. #2
  3. Moderator From Beyond
    ASP Mastermind (5000+ posts)

    Join Date
    Sep 2004
    Location
    Israel
    Posts
    31,135
    Rep Power
    2924
    for IE browser:
    Code:
    <input type="button" value="Close" onclick="opener.opener=opener; opener.close(); self.close();" />
    clicking this button in the popup window should close its opener and the popup itself.
    in Firefox or any sane browser it's not possible though.
  4. #3
  5. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Nov 2006
    Location
    Mumbai
    Posts
    2
    Rep Power
    0
    Originally Posted by Shadow Wizard
    for IE browser:
    Code:
    <input type="button" value="Close" onclick="opener.opener=opener; opener.close(); self.close();" />
    clicking this button in the popup window should close its opener and the popup itself.
    in Firefox or any sane browser it's not possible though.
    Thanks its working.

Similar Threads

  1. Windows 2003 Server
    By awar90 in forum Visual Basic Programming
    Replies: 2
    Last Post: September 13th, 2004, 07:12 PM
  2. SQL Query question...
    By LilMoke in forum SQL Development
    Replies: 3
    Last Post: June 16th, 2004, 09:23 AM
  3. javascript commands not doing anything
    By cal_gecko in forum HTML, JavaScript And CSS Help
    Replies: 1
    Last Post: April 11th, 2004, 03:39 PM
  4. close a browser session with vbscript or javascript
    By Steve Schofield in forum ASP Development
    Replies: 1
    Last Post: April 2nd, 2001, 04:44 AM

IMN logo majestic logo threadwatch logo seochat tools logo