时间: 2021-07-31 作者:daque
test.htm
<html><head><meta http-equiv="content-type" content="text/html; charset=utf8"><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.document.write("<input type='button' value='革新你窗口' onclick='window.opener.location.reload()'>");}</script><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>
运转功效如次: