问题:如果以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()'>
<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()'>
直接给它赋值
var a = openModelDialog(...)的, 在关闭那窗口时, 设置
window.returnValue = "";
父窗口取得a后判断是否null, 非空的话就给页面元素赋值
opener.document.all("t_areacode").value = 值;showModelDialog()如上.
window.parent.document
2,
window.dialogArguments.parent
楼主也不要太懒了,把任务贴出来让大家做得了.
window.opener.documnet修正一下
window.opener.document
为空或不是对象啊!!!天,救命啊。
<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>
够清楚了吧,不要忘记给我银子噢^-^