隨筆-16  評論-8  文章-30  trackbacks-0
            用window.openr打開的子父窗口之間的操作跟框架的是不一樣的,子窗口和父窗口之間有opener來聯系。而源窗口要訪問子窗口要通過其句柄來操作。以下小例子希望能幫助新手更了解他們的操作。

          test.htm  

          <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.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>

          posted on 2005-06-10 14:31 楚客 閱讀(208) 評論(0)  編輯  收藏 所屬分類: HTML
          主站蜘蛛池模板: 岳池县| 永新县| 南郑县| 延边| 衡阳市| 偏关县| 富蕴县| 宣武区| 行唐县| 沧源| 无锡市| 林周县| 南木林县| 高尔夫| 榆树市| 宜兰县| 东宁县| 香河县| 固安县| 安宁市| 公安县| 湖口县| 罗城| 洪江市| 阜新| 贺兰县| 扎兰屯市| 赤城县| 六盘水市| 微博| 二连浩特市| 闸北区| 庆城县| 安陆市| 江口县| 宁南县| 洪雅县| 东方市| 巴楚县| 毕节市| 贡嘎县|