解决window.showModalDialog在Firefox无法支持

世界上为什么有那么多的浏览器,兼容性,我擦。。。

貌似火狐3以上的版本能支持子窗口关闭后showModalDialog传值了,但我项目上一直不行,郁闷中,,解决方案


在一个父窗口中打开一个子窗口,并把子窗口的值传递给父窗口

在父窗口中:

<script language="javascript">
function colorpick(obj){
if (window.showModalDialog!=null)//IE判断
{
var smd= window.showModalDialog("Default2.aspx","","dialogWidth:225px;dialogHeight:170px;status:no;help:no;scrolling=no;scrollbars=no");
if(smd!=null)
obj.style.background=rtn;
return;
}
else
{
this.returnAction=function(strResult){
if(strResult!=null)
obj.style.background=strResult;
}
window.open("Default2.aspx","","width=225,height=170,menubar=no,toolbar=no,location=no,scrollbars=no,status=no,modal=yes");
return;
}

}
</script>

在子窗口中:

function act(RGB) {
if (window.showModalDialog!=null)//IE判断
{
parent.window.returnValue="#"+RGB;
window.close();//firefox不支持

}
else
{
window.opener.returnAction("#"+RGB);
top.close();//IE和FireFox都支持
}
}

你可能感兴趣的:(浏览器,IE,firefox)