Passing values from popup window to the parent window

Discussion in 'JavaScript' started by mk1336, Sep 11, 2008.

  1. #1
    Hi,

    I have a popup window which have many records link (values)dynamically created.

    By clicking on the links value on the popup window (child) the JavaScript should pass value one by one and creates a link on the parent window.

    Is it possible to pass value from child window one by one to the parent window and based on each click the parent window creats a link?

    Thanks,


    MK
     
    mk1336, Sep 11, 2008 IP
  2. drunnells

    drunnells Peon

    Messages:
    79
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Maybe this will be of some use to you. I believe that the two html documents below get the effect you are looking for. When you open popup_test_parent.html in a browser and click the open new window link a popup opens with a list of items, clicking any of these items will add a url to the parent window:

    popup_test_parent.html
    <html>
    <head>
    <script language=JavaScript>
    function addLink(inUrl) {
            var theLinkList = document.getElementById('linkList');
            theLinkList.innerHTML = theLinkList.innerHTML + "<a href=" + inUrl + ">" +inUrl + "</a><br>";
    }
    </script>
    </head>
    <body>
            <h3>Click <a href=# onClick="javascript:window.open('popup_test_sub.html','LinksPage','width=400,height=400,resizable=1,margin=0,scrollbars=1'); return false;">here</a> to add some links below.</h3><p>
            <div id=linkList></div>
    </body>
    </html>
    HTML:
    popup_test_sub.html
    <html>
    <body>
    Click an item below to add it to the parent window:<p>
    <li><a href=# onClick='window.opener.addLink("http://firstUrl");return false;'>First Item</a>
    <li><a href=# onClick='window.opener.addLink("http://secondUrl");return false;'>Second Item</a>
    <li><a href=# onClick='window.opener.addLink("http://thirdUrl");return false;'>Third Item</a>
    </body>
    </html>
    HTML:
     
    drunnells, Sep 18, 2008 IP