www.webdeveloper.com
Results 1 to 4 of 4

Thread: child to parent links

  1. #1
    Join Date
    Oct 2010
    Posts
    2

    child to parent links

    I have a parent window that opens up a child window with a list of links. The child window needs to stay on the same page and when the links are clicked they affect the parent window. Right now both of the windows are changing and I just need the parent to.

    here is the parent window code: pop-up.php

    Code:
    <body>
    <a href="javascript:void(0);" NAME="My Window Name" title=" My title here " onClick=window.open("pop-up1.php","Ratting","width=550,height=170,0,status=0,");>Click here to open the child window</a>
    </body>

    and the child window code: pop-up1.php

    Code:
    <head>
    <script type="text/javascript">
    function openparent (url) {
    if (window.opener &&!window.opener.closed){
    window.opener.location = url;
    window.close();
    }
    }
    </script> 
    </head>
    <body>
    <a href="green.php" onclick="openparent(this.href)"> a</a>
    <br  />
    <a href="index.php" onclick="openparent(this.href)"> 3</a>
    </body>
    Thanks for any input you have!!!

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Not very clear. So far you have:
    Code:
    window.opener.location = url;
    That should change the parent's url
    Code:
    window.close()
    that should close the popup. OK. So? Both windows "are changing", as you said, but this is exactly what your code should do.

  3. #3
    Join Date
    Oct 2010
    Posts
    2
    oops I didn't realize I still had the window close in there.

    This is what I have been working with:




    Code:
    <body>
    <a href="javascript:void(0);" NAME="My Window Name" title=" My title here " onClick=window.open("pop-up1.php","Ratting","width=550,height=170,0,status=0,");>Click here to open the child window</a>
    </body>
    and the child window code: pop-up1.php

    Code:
    <head>
    <script type="text/javascript">
    function openparent (url) {
    if (window.opener &&!window.opener.closed){
    window.opener.location = url;
    }
    }
    </script> 
    </head>
    <body>
    <a href="green.php" onclick="openparent(this.href)"> a</a>
    <br  />
    <a href="index.php" onclick="openparent(this.href)"> 3</a>
    </body>
    All I want to do is have the child window stay on the same page with the links in that window changing the parent window only. thanks again.

  4. #4
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    When you change the href of the opener you change the opener's session, thus you destroy the JavaScript relationship opener-popup. The popup becomes independent. This is it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles