<head><title>父页面</title></head>
<body>
<form name="form1" id="form1">
<input type="text" name="username" id="username"/>
</form>
<iframe src="b.html" width=100%></iframe>
</body>
</html>
var _parentWin = window.parent ;
_parentWin.form1.username.value = "xxxx" ;
</script>
function openSubWin()
{
var _width = 300 ;
var _height = 200 ;
var _left = (screen.width - _width) / 2 ;
var _top = (screen.height - _height) / 2 ;
window.open("b.html",null,
"height=" + _height + ",width=" + _width + ",status=no,toolbar=no,menubar=no,location=no,resizable=yes,left=" + _left + ",top=" + _top);
}
</script>
<input type="text" name="username" id="username"/>
<input type="button" value="弹出子页面" onClick="openSubWin();">
function UpdateParent()
{
var _parentWin = window.opener ;
_parentWin.form1.username.value = "xxxx" ;
//或者:window.opener.document.getElementById("username").value = "xxxx";
}
</script>
<input type="button" name="button" id="button" value="更新主页面的UserName内容" onClick="javascript:UpdateParent();">