第一页1.htm
<script>
function OpenWin(form)
{
//showModelessDialog
var str = window.showModalDialog('2.htm',form,
'dialogWidth:300px; dialogHeight:201px; center:yes');
if(str != null)
document.forms[0].textb.vaule = str;
}
</script>
<form name="form1" method="post" action="" onsubmit="return false" >
<input type="text" name="textb" />
<input type = "submit" name = "submit" value = "打开新窗口" onclick= "OpenWin(this.form);" />
</form>
第二页2.htm
<title>Dialog</title>
<script>
function back()
{
window.dialogArguments.textb.value=document.form1.text1.value;
self.close();
}
</script>
<body>
<form name="form1" method="post" action="#" onSubmit="back()" >
<input type="text" name="text1" />
<input type = "submit" name = "submit" value = "返回" />
</form>
</body>
note :在第二页要注意一点就是 当提交的时会打一个新的窗体,把action 设为“#”,就不会这个情况。