兼容IE和FF的居中弹出窗口

最近在公司接手了以前的老项目,要对浏览器兼容进行改造,以前只是针对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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值