问题:如果以window.showModalDialog()方式打开的窗口,怎么将子窗口的值传回父窗口,下面这两个页面不能正确返回,怎么回事呢?:
<script language="javascript">
<!--
function doMDb(url)
{
window.showModalDialog("selectb.jsp",window,'scroll:0;status:0;help:0;resizable:0;dialogWidth:240px;dialogHeight:200px');
return false;
}
-->
</script>
<form name=add method=post action=#>
<input type="text" id="bdepartment" name="bdepartment" size="20">
<input type="submit" value="选择" name="b3" onclick="return doMDb();">
</form>selectb.jsp
<script language="javascript">
function showselect(aa)
{
var aa=opener.document.add.bdepartment.value="贵州";
return true;
window.close();
}
</script>
<input type='submit' name='b1' value='确定' onclick='showselect()'>

解决方案 »

  1.   

    windows.open打开的窗口可以通过parent.document.all("t_areacode").value = "";
    直接给它赋值 
    var a = openModelDialog(...)的, 在关闭那窗口时, 设置
    window.returnValue = "";
    父窗口取得a后判断是否null, 非空的话就给页面元素赋值
      

  2.   

    关于window.open()打开窗口,可以用:
    opener.document.all("t_areacode").value = 值;showModelDialog()如上.
      

  3.   

    1,
    window.parent.document
    2,
    window.dialogArguments.parent
    楼主也不要太懒了,把任务贴出来让大家做得了.
      

  4.   

    1.
    window.opener.documnet修正一下
      

  5.   

    晕,再修正一下1.
    window.opener.document
      

  6.   

    window.opener.document
    为空或不是对象啊!!!天,救命啊。
      

  7.   

    主网页 main.asp
    <html>
    <head>
    <script language=javascript>
    <!--
    function ToGetData()
    { var HadData=window.showModalDialog("children.asp",window,'scroll:0;status:0;help:0;resizable:0;dialogWidth:240px;dialogHeight:200px');
    myform.databox.value=HadData
    }
    -->
    </head>
    <body>
    <form name=myform>
    <input name=databox onclick="ToGetDate()">
    </form>
    </body>
    </html>
    子网页 children.asp
    <html>
    <head>
    <script language=javascript>
    <!--
    function go()
    { window.returnValue=dataform.datasource.value
    }
    -->
    </head>
    <body onunload="go()">
    <form name=dataform>
    <input name=datasource >
    </form>
    </body>
    </html>
    够清楚了吧,不要忘记给我银子噢^-^