Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I close the parent window with a child window.

    I have used a javascript code to have a brand new window pop up on load which minimizes itself while the popup window says visible. The parent window also has a code where it will close the loaded pop-up window if it closes itself. I would like to be able to close the parent window with a button on the new pop-up window so that both windows are closed at the same time. Is that possible?

    Thank you for your help.

    -Haris B.

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    <a href="javascript:opener.close();">Close Parent Window</a>

    Note that trying to close the parent window will generate an alert telling the user that the web page is attempting to close their main browser window and then ask them if they wish to proceed. That is a security feature built into the browser so no getting around it.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I just tried it it doesn't seem to work.
    It doesn't close any windows at all.

    Any other ways of doing it?

    -Haris B

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Let's see your code.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #5
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #6
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Originally posted by beetle
    Not so fast! Check this out! :D

    http://aspalliance.com/peterbrunone/impossible.asp
    Interesting. The article is misleading though. You can close the parent window without changing the status of the parent window. It will just prompt the user to close it. But utilizing their technique that parent window can be closed without the prompt.

    Note: If you are doing this you will irritate the users when you close their parent window unless of course it is a window that you opened beyond the users first window.

    Anyways to summarize it works as follows:

    Code that goes inside the popup window:

    Code:
    <html>
    <head>
    <title>Your Popup window</title>
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <a href="javascript:opener.close();">Close Parent Window</a>
    </body>
    </html>
    Code that goes in your parent window:

    Code:
    <html>
    <head>
    <title>Parent Window</title>
    
    <script language="javascript">
    <!--//
    function popup(url,windowname,w,h,x,y){
    	popwin = window.open(url,windowname,"resizable=no,toolbar=no,scrollbars=no,menubar=no,status=no,directories=no,width="+w+",height="+h+",left="+x+",top="+y+"");
    }
    
    window.opener = top;
    //-->
    </script>
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <a href="javascript:popup('popup.html','mypopup','335','255','50','50');">Open Popup Window</a>
    </body>
    </html>
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #7
    New to the CF scene
    Join Date
    Aug 2002
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    THANKS IT WORKS



  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •