<!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 οnclick="openNewWindow();">打开新窗口</button> <hr> 此文本框的值要从子窗口中取得 <input type="text" id="parentText"> </body> </html>
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/caoyinghui1986/archive/2008/06/15/2549373.aspx
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 οnclick="funClose();">关闭本窗口</button>
<hr>
此文本框的值将要传递到父窗口
<input type="text" id="childText" value="子窗口的值:1">
</body>
</html>