0

有人可以帮我吗?我有一个父窗口和一个弹出窗口。我希望他们交流,但代码有问题。请告诉我有关 javascript 或 jquery 的信息。我只想让弹出窗口也控制父窗口。

我的 index.html

<html>
<head>
<script>
function openwindow() { window.open("pop.html","mywindow","menubar=1,resizable=1,width=400,height=400"); }
</script>
</head>
<body>
<a href="href="javascript: openwindow()"" id="will-hide-in-pop">Show pop up!</a>
</body>
</html>

然后我们点击锚点后,弹出窗口将显示。这是带有表单的弹出代码: 弹出代码:

<html>
<head>
<script>
function clicked(){window.opener.document.getElementById('will-hide-in-pop').style.display="none"; }
</script>
</head>
<body>
<div>
<form action="process.php" method="GET">
<input type="text" name="text" />
<input type="checkbox" name="cbox" />
<input type="submit" name="" onclick="clicked()"/>
</form>
</div>
</body>
</html>

我输入了正确的代码吗?我只想要表单提交后,父窗口中的锚点也会消失

请帮我

4

2 回答 2

0

尝试在 jQuery 提交中调用您的函数:

 $(document).ready(function () {
     $('form').submit(function () {
         clicked();             
      });       
 });
于 2013-03-06T14:17:06.037 回答
0

注意选择器:.getElementById('will-hide-in-pop') 在弹出窗口中,您使用 getElementById,但在索引中,有 class="will-hide-in-pop"。

于 2013-03-06T14:17:18.703 回答