javascript showModalDialog传值与FireFox的window.open 父子(2)


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>a.html文档</title>
<script language="javascript">
function openstr()
{
ReturnValue=window.showModalDialog("b.html",window,"dialogWidth=510px;dialogHeight=150px;status=no");
if(ReturnValue && ReturnValue!="")
{
oOption = document.createElement('OPTION');
oOption.text=ReturnValue;
oOption.value=ReturnValue;
document.all.txtselect.add(oOption);
}
}
</script>
</head>
<body>
<form method="post" action="">
<label>
<select>
</select>
</label>
<label>
<input type="button" value="打开子窗口" />
</label>
</form>
</body>
</html>


b.html

复制代码 代码如下:


<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>b.html文档</title>
<script language="javascript">
function ClickOk()
{
var t=document.Edit;
var url=t.color.value;
if(url==null||url=="填写颜色") return(false);
window.returnValue=url;
window.close();
}
</script>
</head>
<body>
<table cellpadding="0" cellspacing="2">
<form>
<tr>
<td>color:</td>
<td><input type="text" value="填写颜色" /></td>
<td><input " type="button" value="确认" /> </td>
</tr>
</form>
</table>
</body>
</html>
修改为兼容IE和FireFoxr的代码如下:
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>a.html文档</title>
<script type="text/javascript">
function openstr()
{
window.open("b.html","","modal=yes,width=500,height=500,resizable=no,scrollbars=no");
}
</script>
</head>
<body>
<form method="post" action="">
<label>
<select>
</select>
</label>
<label>
<input type="button" value="打开子窗口" />
</label>
</form>
</body>
</html>


b.html

复制代码 代码如下:


<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>b.html文档</title>
<script type="text/javascript">
function ClickOk()
{
var t=document.Edit;
var color=t.color.value;
if(color==null||color=="填写颜色") return(false);
var oOption = window.opener.document.createElement('OPTION');
oOption.text=url;
oOption.value=url;
//检查浏览器类型
var bname = navigator.appName;
if (bname.search(/netscape/i) == 0)
{
window.opener.document.getElementById("txtselect").appendChild(oOption);
}
else if (bname.search(/microsoft/i) == 0)
{
window.opener.document.all.txtselect.add(oOption);
}
else
{
}
window.close();
}
</script>
</head>
<body>
<table cellpadding="0" cellspacing="2">
<form>
<tr>
<td>color:</td>
<td><input type="text" value="填写颜色" /></td>
<td><input " type="button" value="确认" /> </td>
</tr>
</form>
</table>
</body>
</html>


1

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjyygg.html