如何获得子窗口的子窗口

F1_bxf 2008-01-08 10:32:00
做一个A.html ,此中单击按钮弹出B.html,再在B中单击按钮弹出C.html,这时C是B的子窗口,B是A的子窗口。所以C是A的孙子窗口。
现在想在关闭A的时候同时关闭这两个(B.html,C.html)窗口,如何实现?
对Javascript不熟。望指导。
...全文
130 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
F1_bxf 2008-02-03
  • 打赏
  • 举报
回复
谢谢.
如LS所写,解决了html.
tanlingyun 2008-01-08
  • 打赏
  • 举报
回复
A:

<html>
<head>
<script language="JavaScript">
var newWindow;
function createNewWindow()
{
newWindow=window.open("B.html","_blank","height=300,width=300");
}
function closeNewWindow()
{
if(newWindow)
{
newWindow.newWindow.close();
newWindow.close();
newWindow=null;
newWindow=null;
}
}
</script>
</head>
<body onunload="closeNewWindow()">
<form>
<input type="button" value="点击创建新窗口" onclick="createNewWindow()"/>
<input type="button" value="关闭新窗口" onClick="closeNewWindow()"></input>
</form>
</body>
</html>


B.html

<html>
<head>
<script language="JavaScript">
var newWindow;
function createNewWindow()
{
newWindow=window.open("C.html","_blank","height=300,width=300");
}
function closeNewWindow()
{
if(newWindow)
{
newWindow.close();
newWindow=null;
}
}
</script>
</head>
<body onunload="closeNewWindow()">
<h1>子页</h1>
<form>
<input type="button" value="点击创建新窗口" onclick="createNewWindow()"/>
<input type="button" value="关闭新窗口" onClick="closeNewWindow()"></input>
</form>
</body>
</html>


C.html

子子页
rjzou2006 2008-01-08
  • 打赏
  • 举报
回复
子窗口是iframe?

既然是iframe,关A了就会全关的.

87,915

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧