window.close()问题

ccllxw2 2010-01-25 11:45:45
我在a.html使用 window.open()打开一个b.html窗口后 然后想关闭a.htlm
于是就在window.open()后加了句 window.close(); 但结果是 a b两个窗口全关掉了 怎么回事啊
或者哪位朋友能告诉我其他实现的方法
下面是全部代码
<html>
<head》
<title>My JSP 'success.jsp' starting page</title>
<script type="text/javascript">
function openMyWindow(url,name,iWidth,iHeight){
var url;
var name;
var iWidth;
var iHeight;
//获得窗口的垂直位置
var iTop = (window.screen.availHeight-30-iHeight)/2;
//获得窗口的水平位置
var iLeft = (window.screen.availWidth-10-iWidth)/2;
window.open(url,name,'height='+iHeight+',,innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=0,titlebar=no');
window.close();
}
</script>
</head>

<body>
<script type="text/javascript">
window.onload =openMyWindow('/zhanxi/web/Booktree/index.jsp','openbooktree',1000,600);
</script>

</body>
</html>
...全文
122 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
liting68 2010-01-27
  • 打赏
  • 举报
回复
js有安全限制,不能用js打开的子页面去关闭父级的页面
yingzhilian2008 2010-01-27
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 xiangchengboy 的回复:]
window.close();window.open()
顺序问题
[/Quote]可以的把
呼吸先生 2010-01-25
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 ccllxw2 的回复:]
1楼能说详细点吗  我的JS很菜的
[/Quote]
按照我在5楼说的,把你参数加后面就可以了。不知道能满足你不?
呼吸先生 2010-01-25
  • 打赏
  • 举报
回复
不好意思,上一条写错了。
window.open(url,"_top",""); 具体LZ百度一下window.open()的用法吧。
ccllxw2 2010-01-25
  • 打赏
  • 举报
回复
2楼 把打开的页面关了 也就是上面说的 b页面关了 a页面没关
ccllxw2 2010-01-25
  • 打赏
  • 举报
回复
1楼能说详细点吗 我的JS很菜的
xmliy 2010-01-25
  • 打赏
  • 举报
回复
var w = window.open(....);
w.close();
呼吸先生 2010-01-25
  • 打赏
  • 举报
回复
target="_selft"
xiangchengboy 2010-01-25
  • 打赏
  • 举报
回复
window.close();window.open()
顺序问题
呼吸先生 2010-01-25
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 frankyhuang2010 的回复:]
试一下: target="_self"
[/Quote]
target="_self"换成
window.open(url,"_top","");
换成_top可以。。
frankyhuang2010 2010-01-25
  • 打赏
  • 举报
回复
试一下: target="_self"

87,903

社区成员

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

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