您现在的位置是:首页 > 电脑技术查询 > web开发

子窗口向父窗口传递数据的有关问题

编辑:chaxungu时间:2022-10-02 23:20:15分类:web开发

子窗口向父窗口传递数据的问题
在网上找到一段代码,

a.htm
-----
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 新建网页 1 </title>
</head>
<body>
<TEXTAREA id= "content " name= "content " cols= "50 " rows= "5 "> </TEXTAREA>
<INPUT type= "button " onclick= "window.showModalDialog( 'dialog.htm ',content, ' '); " value= "Test ">
</body>

</html>


dialog.htm
---------
<html>

<script language= "javascript ">

function closeWin()
{

var retValue = " ";

for(i=0;i <chkBox.length;i++)
{
if(chkBox[i].checked)
retValue += chkBox[i].value + ", ";
}

window.dialogArguments.value = retValue;
window.close();

}

</script>

<body>

<input type= "checkbox " id= "chkBox " value= "ABC "> ABC <BR>
<input type= "checkbox " id= "chkBox " value= "DEF "> DEF <BR>
<input type= "checkbox " id= "chkBox " value= "GHI "> GHI <BR>
<input type= "button " value= "ok " onclick= "closeWin(); ">

</body>

</html>

经过测试,只能支持IE, 用firefox不行,怎么才能支持firefox?

------解决方案--------------------
这个问题,几年前就有人提交到了 Mozilla 的 Bugzilla,请见 Bug 194404

在最初 MozillaSuite 中(Firefox 是从这个套件衍生),是支持 showmodaldialog() 的,不过后来发现 showmodaldialog() 存在安全隐患,不久后就取消了对 showmodaldialog() 的支持,这个事情还发生在 bug 194404 提交前。在想出更好的解决方案前,相信 Firefox 是不会提供对 showmodaldialog() 的支持的。