日期:2014-05-19  浏览次数:20357 次

这种问题应该怎么办呀?
在主页面我点一按钮弹出一个新对话框,当我关闭这个新对话框时,如何才能将新对话框的值写到我的主页面的某个文本框并显示出来,关闭新窗体时好像原来的页面不会刷新!!

------解决方案--------------------
使用showModalDialog()
------解决方案--------------------
1.html
<script type= "text/javascript ">
function btnOpen_Click()
{
//document.MainForm.txtValue.value = window.open( "2.html ", null, "height=300,width=300,status=no,toolbar=no,menubar=no,location=no ");
document.MainForm.txtValue.value = window.showModalDialog( "2.html ");
}
</script>
<form name = "MainForm ">
<input type = "button " value= "Click " name = "btnOpen " onClick= "btnOpen_Click(); " />
<input type = "text " name = "txtValue " />
</form>


2.html
<script type= "text/javascript ">
function btnOpen_Click()
{
window.returnValue = document.Form1.txtValue.value;
alert (document.Form1.txtValue.value);
window.close();
}
</script>
<form name = "Form1 ">
<input type = "button " value= "Click " name = "btnOpen " onClick= "btnOpen_Click(); " />
<input type = "text " name = "txtValue " />
</form>