window.opener 返回的是创建当前窗口的那个窗口的引用,比如点击了a.htm上的一个链接而打开了b.htm,然后我们打算在b.htm上输入一个值然后赋予a.htm上的一个id为“name”的textbox中,就可以写为:
window.opener.document.getElementById("name").value = "输入的数据";
DEMO
page1.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>

<script language="javascript">


function openwin(url,wh,hg,lf,tp)
{
var newwin=window.open(url,"newwin","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width="+wh+",height="+hg+",left="+lf+",top="+tp);
newwin.focus();
return false;
}


function openwin1(url)
{
var newwin=window.open(url,"newwin","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes");
newwin.focus();
return false;
}

</script>
</head>

<body>
<input name="name" type="text" />
<input type="button" onClick="openwin1('page2.html')" value="abc" />
</body>
</html>page2.html


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>

<script language="javascript">
function myclose()


{
window.opener.document.getElementById("name").value="OK";

/**//*window.opener.document.cus.name.value="OK";*/
window.close();
}
</script>
</head>

<body>

abc
<input name="close" type="button" onClick="myclose()" value="close" />
</body>
</html>
