欢迎来到飞鸟慕鱼博客,开始您的技术之旅!
当前位置: 首页知识笔记正文

子窗口和父窗口之间操作的小例子

墨初 知识笔记 73阅读

1用window.openr打开的子窗口和父窗口之间的操作与框架不同,子窗口和父窗口之间有一个打开器。而由源窗口访问子窗口由其句柄操作。下面几个小例子希望能帮助新手更好的理解操作。23test.htm 45 html 6 head 7 meta http-equiv=' Content-Type ' Content=' text/html;charset=gb2312'8nbsp。meta name=' generator ' content=' Microsoft front page 4.0 ' 9 meta name=' progid ' content=' front page . editor . document ' 10子窗口和父窗口的标题操作/title11/

style="color: rgba(0, 0, 0, 1)">head>
12 <body>
13 <script>
14 var win=null;
15 function op(){
16 win=window.open("about:blank","win","width=200,height=200");
17 win.document.write("<input type='button' value='关闭父窗口' onclick='window.opener.opener=null;window.opener.close()'>");
18 win.document.write("<input type='button' value='刷新你窗口' onclick='window.opener.location.reload()'>");
19 }
20 </script>
21 <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('还没有打开窗口或者已关闭')};">
22 </body>
23 </html>
24 
25 

标签:
声明:无特别说明,转载请标明本文来源!