test.htm:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>test title>
<Script>
function openWin()
{
var rt=window.showModalDialog("Client.htm",window,"dialogwidth:200px;dialogheight:200px");
if(rt)
{
myfrm.txtValue.value=rt;
}else{
myfrm.txtValue.value="";
}
}
</Script>
</head>
<body>
<form name="myfrm">
<p>
<input type="text" Name="txtValue" value="">
<input type="button" value="打开" onclick="openWin()">
</p>
</form></body>
</html>
Client.htm
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Client</title>
<Script>
function OK()
{
window.returnValue=form1.txtName.value;
window.close();
}
function getValue()
{
form1.txtName.value = window.dialogArguments.myfrm.txtValue.value;
}
function setValue()
{
window.dialogArguments.myfrm.txtValue.value = form1.txtName.value;
}
</Script>
</head>
<body onLoad="getValue()">
<form action="" method="post" name="form1">
<input type="text" name="txtName" value="">
<input type="button" value="确定" onclick="OK()">
<input type="button" value="设置" onclick="setValue()">
</form>
</body>
</html>