showModalDialog() 改变源窗口的内容
showModalDialog() 改变源窗口的值:
<1>打开新的对话框窗口时,第二个参数需要是window,以便将自己传送到对话框中。
showModalDialog("002.htm",window,"");
<2>在新打开的对话框页面中就可以通过dialogArguments来访问源页面:
示例:
001.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script type="text/javascript" >
function doing()
{
showModalDialog("002.htm",window,"");
}
function ChangingValue_002(strValue)
{
document.getElementById("someValue").value = strValue;
}
</script>
</HEAD>
<BODY>
<input type="text" id="someValue" />
<input type="button" value="打开" onclick="doing();" />
</BODY>
</HTML>
002.htm:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script type="text/javascript" >
function changing()
{
dialogArguments.document.getElementById("someValue").value="ohmygod!";
}
function changing_2()
{
dialogArguments.ChangingValue_002("方法二,回传的值");
}
</script>
</HEAD>
<BODY>
<input type="button" onclick="changing()" value="改变原来的值" />
<input type="button" onclick="changing_2()" value="改变原来的值" />
</BODY>
</HTML>