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 阅读(818) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 
<2008年6月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

导航

统计

常用链接

留言簿

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜