最近在公司接手了以前的老项目,要对浏览器兼容进行改造,以前只是针对ie,现在要求FireFox下也要兼容,其他系统中用到了大量的弹出窗口,在IE下弹出窗可以居中,但是FireFox下不行,上网查了些资料,貌似FF就是不支持弹出窗口居中,杯具了只有自己去写个方法了,下面是实现的代码,目前在FF只是实现在屏幕的中间弹出
<script language="javascript" type="text/javascript">
function openMyWin(url,title,obj,width,height){
var parm = "";
var dialogHeight = "dialogHeight:"+height+"px";
var dialogWidth = "dialogWidth:"+width+"px";
if(navigator.userAgent.toLowerCase().indexOf('msie')>0){
parm = dialogHeight+";"+dialogWidth+";center=yes";
}else{
var x = (window.screen.width/2)-(width/2)+"px";
var y = (window.screen.height/2)-(height/2)+"px";
parm = dialogHeight+";"+dialogWidth+";dialogLeft:"+ x +";dialogTop:"+y+";";
}
var returnValue = window.showModalDialog(url,title,parm);
return returnValue;
}
</script>