接收用showModalDialog打开模式窗口返回的值 
 
win1.htm<HTML>
<HEAD>
<TITLE>showModalDialog窗口传值</TITLE>
<script language="JavaScript">
function showModal(){
 rtn=window.showModalDialog('win2.htm');
 s="";
 for(elem in rtn){
 alert(rtn[elem]);
 s+=rtn[elem];
 }
 document.all["textarea"].value=s;
 
}
</script>
</HEAD>
<BODY BGCOLOR="antiquewhite"><FORM NAME="form1">
<textarea name="textarea"></textarea>
<P><INPUT TYPE="button" VALUE="Open a message window"
   onClick = "showModal()"></BODY>
</HTML>win2.htm<HTML>
<HEAD>
<TITLE>Window object example: Window 2</TITLE>
</HEAD>
<BODY BGCOLOR="oldlace"
   onUnload="collectRtn()">
    <input name="textfield1" type="text" id="textfield1">
    <input type="text" name="textfield2">
    <input name="textfield3" type="text" id="textfield3">
    <input name="textfield4" type="text" id="textfield4"><script language="javascript">
function collectRtn(){
s=new Array();
for(i=1;i<=4;i++){
tf=document.getElementById("textfield"+i);
s[i]=tf.value;
}
window.returnValue=s;
}
</script>
</BODY>
</HTML> 

解决方案 »

  1.   

    引用net_lover的:var s = showModalDialog('ttt.htm','','dialogWidth: 480px; dialogHeight: 360px; status: no; help: no');
    if(s)
    {
      alert(s); //得到回传值
    }ttt.htm:
    <input type="button" value="close"
     onclick="window.returnValue='mm'; window.close()" />window.returnValue 赋上你想要回传的信息
      

  2.   

    var aa = "要传入的值";
    var s = showModalDialog('b.html', aa, 'scrollbars=yes;resizable=no;help=no;status=no;dialogHeight=600px;dialogWidth=800px');
    if(s)
    {
      alert("模态框返回值: "+ s);
    }b.html:
    <body onload="mm.value=window.dialogArguments">
    <TEXTAREA id="mm" NAME="aa" ROWS="" COLS=""></TEXTAREA>
    <INPUT TYPE="button" value="确定" onclick="window.returnValue=mm.value; window.close()">