Javascript window.opener不工作

Javascript window.opener不工作,javascript,jquery,html,Javascript,Jquery,Html,我正在制作一个网页,通过单击父窗口上的图像打开一个弹出的子窗口 我想将值从子窗口的文本框传递到父窗口的文本框 我找到了关于这个主题的教程,并遵循了他的方法。 然而,这对我来说不起作用 $(document).ready(function(){ $("#myImg").click(function(){ var win1=window.open("popupWindows/p1.html","myWindow"," top=500, left=500, width=500,hei

我正在制作一个网页,通过单击父窗口上的图像打开一个弹出的子窗口

我想将值从子窗口的文本框传递到父窗口的文本框

我找到了关于这个主题的教程,并遵循了他的方法。 然而,这对我来说不起作用

$(document).ready(function(){
  $("#myImg").click(function(){   
    var win1=window.open("popupWindows/p1.html","myWindow"," top=500, left=500, width=500,height=500");
    });
});
^这将打开子窗口

function childWindowFunction()
{
opener.document.getElementById("parentTextBox").value=document.getElementById("userInput").value;
//alert(document.getElementById("userInput").value); <-- this works
//alert(opener.document.getElementById("parentTextBox").value); <-- not working at all
close();
}
函数childWindowFunction()
{
opener.document.getElementById(“parentTextBox”).value=document.getElementById(“userInput”).value;

//警报(document.getElementById(“userInput”).value);想象一下,您使用window.open创建“myWindow”,然后在“myWindow”中使用window.open创建“WindowTheQuel”

您现在有两个“打开器”,例如原始浏览器窗口和“myWindow”。因此,如果没有子窗口(myWindow)作为引用,打开器将不知道引用哪个窗口


因此,以
myWindow.opener…
开始这一行,你就可以开始了。

你检查过
opener
opener.document
了吗
opener.document.getElementById(“parentTextBox”)是什么意思
return?@TarunPai当你打开一个新窗口时-
opener
是打开该窗口的窗口,我遵循了一个教程的说明,其中函数post_value(){opener.document.f1.p_name.value=document.frm.c_name.value;self.close()}可以将子窗口的值传递给父窗口。教程URL:@James_uu你能在JSFIDLE上托管你的代码吗?@James_u我在
Sandbox.7z
文件中没有看到任何与
opener
相关的代码。另外,请确保你没有丢失任何文件引用。