子窗口中一按钮,实现关闭父窗口操作。ie6 下:opener.opener=null;opener.close();可实现。ie7下上述方法会出现提示窗口(客户要求直接强行关闭)。
换用opener.opener=null;window.open('','_self'); opener.close(); 。结果第一次出现提示信息,以后就不出现了。有没有其他方法每次都直接关闭父窗口,且每次都不提示。
换用opener.opener=null;window.open('','_self'); opener.close(); 。结果第一次出现提示信息,以后就不出现了。有没有其他方法每次都直接关闭父窗口,且每次都不提示。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>子父窗口的操作</title>
</head>
<body>
<script>
var win=null;
function op(){
win=window.open("about:blank","win","width=200,height=200");
win.document.write("<input type='button' value='关闭父窗口' onclick='window.opener.opener=null;window.opener.close();win.close()'>");
win.document.write("<input type='button' value='刷新你窗口' onclick='window.opener.location.reload()'>");
}
</script>
</body>
</html>
<input onclick="op()" value="打开窗口" type="button"><input type="button" value="最小化" onclick="if(win&&win.open&&!win.closed){win.resizeTo(0,0);win.moveTo(0,window.screen.width);}else alert('还没有打开窗口或已经关闭')"><input type="button" value="最大化" onclick="if(win&&win.open&&!win.closed){win.moveTo(-4,-4);win.resizeTo(screen.availWidth+8,screen.availHeight+8);}else alert('还没有打开窗口或已经关闭');"><input type=button value="关闭子窗口" onclick="if(win&&win.open&&!win.closed){win.opener=null;win.close()}else alert('还没有打开窗口或已关闭')"><input type=button value="刷新子窗口" onclick="if(win&&win.open&&!win.closed){win.location.reload();win.focus()}else alert('窗口还没有打开或已关闭')"><input type="button" value="看子窗口的大小" onclick="if(win&&win.open&&!win.closed) {alert(win.document.body.clientWidth+'*'+win.document.body.clientHeight);win.focus();}else{alert(' 还没有打开窗口或者已关闭')};"></body>
</html>
opener.opener=null;opener.window.open('','_self'); opener.close();