以前我知道在Web中使用模态对话框的时候可以向被打开的窗口传递对象,但是我就是没有想到将父窗口的window对象传递给被打开的窗口,这样就可以在被打开的窗口中控制父窗口中的控件,真是太笨了,害得我以前走了不少弯路,在此与还不了解的朋友分享:
父页面(dialog3.htm):
<HTML>
<HEAD>
</HEAD>
<SCRIPT>
var dWin=null;
function doDialog()
{
dWin=showModelessDialog('dcontent3.htm',window,'status:no;resizable:yes');
}
function setDialogValue()
{
if (dWin != null)
{
dWin.d1.innerHTML=ip1.value;
}
}
</SCRIPT>
<BODY>
This page will invoke my DHTML dialog box when the button is clicked.
<BR><BR>
<INPUT type=text id=ip1 value='input content'>
<BR><BR>
<input type='button' onclick="setDialogValue();"
value="Set Dialog Value">
<BR><BR>
<input type='button' onclick="doDialog();" value="Create Dialog">
<BR><BR>
<DIV id=d1></DIV>
</BODY>
</HTML>
子页面(dcontent3.htm)
<HTML>
<SCRIPT>
function window.onunload()
{
dialogArguments.dWin=null;
}
</SCRIPT>
<BODY style="background-color:lightblue;margin:10;">
This is some content for my DHTML dialog box.
<BR><BR>
<DIV id=d1></DIV>
<BR><BR>
<input type='text' id=ip1 onclick='dialogArguments.d1.innerHTML=ip1.value;'>
<BR><BR>
<input type='button' onclick="dialogArguments.d1.innerHTML=ip1.value;"
value=" Apply ">    
<input type='button'
onclick="dialogArguments.d1.innerHTML=ip1.value;window.close();"
value=" OK ">
   
<input type='button' onclick="window.close();" value=" Cancel ">
</BODY>
</HTML>
演示:http://www.openlab.com.cn/~comy/Sample/dialog3.htm
来源:http://msdn.microsoft.com/library/en-us/dndude/html/dude09252000.asp