说明:
通过window.dialogArguments就可以在子模态窗口里获得父窗口的参数。因为window是顶层对象,所以可以不用写。获得参数后,子窗口运用时就好像在父窗口里使用
<HTML>
<HEAD>
<TITLE>showModelessDialogEX.htm</TITLE>
<SCRIPT>
var sUserName="";
function fnCallDialog(){
showModelessDialog("myDialog.htm",window,"status:false;dialogWidth:300px;dialogHeight:300px");
}
function fnUpdate(){
oName.innerText = sUserName;
}
</SCRIPT>
</HEAD><BODY>
<P>Enter your first name:
<SPAN ID="oName" STYLE="color:red;font-size:24">Joan</SPAN></P>
<INPUT TYPE="button" VALUE="Display Modeless Dialog" οnclick="fnCallDialog()">
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>myDialog.htm</TITLE>
<SCRIPT>
function fnGetInfo() {
var sData = dialogArguments;
sData.sUserName = oEnterName.value;
sData.fnUpdate();
}
function fnCancel() {
var sData = dialogArguments;
sData.sUserName = "Joan";
sData.fnUpdate();
}
</SCRIPT>
</HEAD>
<BODY>
<LABEL FOR="oEnterName" ACCESSKEY="f">
Enter your <SPAN STYLE="text-decoration:underline">F</SPAN>irst Name</LABEL>
<INPUT ID=oEnterName><BR><BR>
<INPUT VALUE="Apply" TYPE=button οnclick="fnGetInfo();">
<INPUT VALUE="Ok" TYPE=button οnclick="fnGetInfo();window.close();">
<INPUT VALUE="Cancel" TYPE=button οnclick="fnCancel();window.close();">
</BODY>
</HTML>
通过window.dialogArguments就可以在子模态窗口里获得父窗口的参数。因为window是顶层对象,所以可以不用写。获得参数后,子窗口运用时就好像在父窗口里使用
<HTML>
<HEAD>
<TITLE>showModelessDialogEX.htm</TITLE>
<SCRIPT>
var sUserName="";
function fnCallDialog(){
showModelessDialog("myDialog.htm",window,"status:false;dialogWidth:300px;dialogHeight:300px");
}
function fnUpdate(){
oName.innerText = sUserName;
}
</SCRIPT>
</HEAD><BODY>
<P>Enter your first name:
<SPAN ID="oName" STYLE="color:red;font-size:24">Joan</SPAN></P>
<INPUT TYPE="button" VALUE="Display Modeless Dialog" οnclick="fnCallDialog()">
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE>myDialog.htm</TITLE>
<SCRIPT>
function fnGetInfo() {
var sData = dialogArguments;
sData.sUserName = oEnterName.value;
sData.fnUpdate();
}
function fnCancel() {
var sData = dialogArguments;
sData.sUserName = "Joan";
sData.fnUpdate();
}
</SCRIPT>
</HEAD>
<BODY>
<LABEL FOR="oEnterName" ACCESSKEY="f">
Enter your <SPAN STYLE="text-decoration:underline">F</SPAN>irst Name</LABEL>
<INPUT ID=oEnterName><BR><BR>
<INPUT VALUE="Apply" TYPE=button οnclick="fnGetInfo();">
<INPUT VALUE="Ok" TYPE=button οnclick="fnGetInfo();window.close();">
<INPUT VALUE="Cancel" TYPE=button οnclick="fnCancel();window.close();">
</BODY>
</HTML>