我有这段代码,我需要在子窗口打开时关闭parent.html窗口,我需要在 IE 和 Firefox 中运行良好的代码
Parent.html
<HTML>
<SCRIPT TYPE="text/javascript">
function sendTo()
{
window.open('child.html','_blank','resizable=yes,width='+(screen.width-500)+',height='+(screen.height-500)+'');
}
</SCRIPT>
<BODY>
<form name="form">
<input type="text" value="" name="text1" id="pdetails1">
<input type="text" value="" name="text1" id="pdetails2">
</br>
<input type="submit" value="submit" onClick="sendTo()">
</BODY>
</HTML>
child.html
<html>
<body>
<form>
<input type=text name="text5" value="">
<input type=submit name="submit"value="submit">
</form>
</body>
</html>
最佳答案
在 child 中:
<script type="text/javascript">
window.opener.close();
</script>
但是,大多数浏览器不允许您这样做。
关于javascript - Firefox中如何在子窗口打开时自动关闭父窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5414618/