caoyinghui

          子窗體如何傳值到父窗體并調(diào)用父窗體的函數(shù)

          <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <script>  //供DEMO02_01頁面的關(guān)閉按鈕調(diào)用  function myFunction(v){   //alert("這里是父窗口中的函數(shù)"+v);   document.getElementById("parentText").value=v;  }  

           //打開新窗口  function openNewWindow(){   window.open("DEMO02_01.html","","height=300;width=300;location=0;status =0;toolbar=0");

           }

          </script> </head>

          <body>

          <button onclick="openNewWindow();">打開新窗口</button> <hr> 此文本框的值要從子窗口中取得 <input type="text" id="parentText"> </body> </html>

          DEMO02_01.html

          <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <script>  function funClose(){      //:調(diào)用父窗體(DEMO02.html)中的myFunction 函數(shù)   //window.opener獲得父窗口的window對象的引用 并調(diào)用 myFunction () 函數(shù)在js中作為window的屬性   window.opener.myFunction(document.getElementById("childText").value);

            window.close();  } </script>

          </head>

          <body> <button onclick="funClose();">關(guān)閉本窗口</button> <hr> 此文本框的值將要傳遞到父窗口 <input type="text" id="childText" value="子窗口的值:1"> </body> </html>

          作者:caoyinghui1986 發(fā)表于2008-6-15 12:31:00 原文鏈接
          閱讀:654 評論:1 查看評論

          posted on 2008-06-15 04:31 shine_panda 閱讀(822) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          <2008年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 黄冈市| 荔浦县| 平原县| 都江堰市| 洪江市| 广平县| 恩施市| 龙口市| 和政县| 武安市| 浏阳市| 社旗县| 莫力| 临猗县| 宿州市| 永顺县| 夏河县| 金昌市| 蕉岭县| 清流县| 冀州市| 兴义市| 宣城市| 固阳县| 桃园市| 南漳县| 朔州市| 高清| 平江县| 安平县| 祁东县| 沙田区| 张家港市| 玛多县| 佛山市| 犍为县| 岗巴县| 白河县| 清河县| 建平县| 滁州市|