caoyinghui

          子窗體如何傳值到父窗體并調用父窗體的函數

          <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <script>  //供DEMO02_01頁面的關閉按鈕調用  function myFunction(v){   //alert("這里是父窗口中的函數"+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(){      //:調用父窗體(DEMO02.html)中的myFunction 函數   //window.opener獲得父窗口的window對象的引用 并調用 myFunction () 函數在js中作為window的屬性   window.opener.myFunction(document.getElementById("childText").value);

            window.close();  } </script>

          </head>

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

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

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


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


          網站導航:
           
          <2008年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          導航

          統計

          常用鏈接

          留言簿

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 乌恰县| 海门市| 咸宁市| 社会| 佛教| 饶平县| 达孜县| 广平县| 南昌市| 宁海县| 溆浦县| 赤水市| 苍梧县| 墨脱县| 通江县| 原阳县| 民县| 当雄县| 奉新县| 孝义市| 彩票| 万州区| 漠河县| 霍林郭勒市| 乐平市| 若羌县| 勃利县| 万州区| 平泉县| 郴州市| 固原市| 麻城市| 东方市| 屯门区| 丰城市| 威海市| 兴山县| 怀集县| 雷波县| 双峰县| 新郑市|