弹出窗口中window.opener中的类实例

时间:2013-12-24 09:12:14

标签: jquery popup instance

我有一个窗口,我点击一个弹出窗口,例如

<td class="links" onclick="openPopUp()">*view profile*</a> 

我有大约10个具有相同名称的类,如何从弹出窗口更改单击类中的文本?

这适用于同一页面$(this).siblings(".links").text("whatever");,但不是来自弹出窗口。谢谢你的帮助

1 个答案:

答案 0 :(得分:0)

你可以这样做......

第1页:Parent.html

Java脚本:

   <script language="JavaScript">
        function getData(txt1,txt2,txt3){
           $("tr td:nth-child(1)").text(txt1)
           $("tr td:nth-child(2)").text(txt2)
           $("tr td:nth-child(3)").text(txt3)
           msgWindow.close();
        }

        function openPopUp(file, window)
        {
            msgWindow = open(file, window, 'scrollbars=yes,resizable=no,width=550,height=400');
            if (msgWindow.opener == null)
                msgWindow.opener = self;
        }
    </script>

HTML:

  <body>
    <form name="parentForm" >
        <table border="1">
            <tr>
                <td class="links" onclick="openPopUp('Popup.html', 'window2')">*view profile 1*</a></td>                 
                <td class="links" onclick="openPopUp('Popup.html', 'window2')">*view profile 2*</a></td>                  
                <td class="links" onclick="openPopUp('Popup.html', 'window2')">*view profile 3*</a></td>   
            </tr>
        </table>
    </form>
</body>

第2页:Popup.html

HTML:

  <body>
    <form name="popupForm" >
        <table border="1">
            <tr>
                <td>Text1</td>                                   
                <td>Text2</td>                                  
                <td>Text3</td>                    
            </tr>
        </table>
    </form>
    <a href="javascript:void();" onclick="window.opener.getData($('tr td:nth-child(1)').text(),$('tr td:nth-child(2)').text(),$('tr td:nth-child(3)').text());return false;">Close</a>
</body>