尝试了此链接的已接受答案, 使用 top.window.opener 访问 parent.html .no lucky 。下面是我的代码
父窗口.html
<p>Click the button to write some text to the source (parent) window.</p>
<button onclick="openWin()">Open "myWindow"</button>
<script>
function test1()
{
alert("test1");
}
function openWin()
{
var myWindow = window.open("childWindow.html");
}
</script>
</body>
</html>
childWindow.html
<HTML>
<HEAD>
<title>Child</title>
<SCRIPT type="text/javascript" LANGUAGE="javascript">
function Initialize()
{
try{
if(top.window.opener != null && !top.window.opener.closed)
{
top.window.opener.test1();
}
}catch(e){ alert(e.description);}
}
</script>
</HEAD>
<BODY onload="Initialize()">
</BODY>
</HTML>
遵循此链接的摘录后,在服务器上尝试了相同的代码。点帮助。