window.open()窗口居中显示

 var iWidth = 400;                         //弹出窗口的宽度;
var iHeight = 450;                        //弹出窗口的高度;
 
var iTop = (window.screen.height-30-iHeight)/2;       //获得窗口的垂直位置;
var iLeft = (window.screen.width-10-iWidth)/2;        //获得窗口的水平位置;

window.open(url,name,'height='+iHeight+',,innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');

可以在a标签里使用

<a onclick="window.open('/e/DownSys/DownSoft/?classid=1&amp;id=1&amp;pathid=0','欢迎下载','height='+iHeight+',,innerHeight='+iHeight+',width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',toolbar=no,menubar=no,scrollbars=auto,resizeable=no,location=no,status=no');"><span>下载</span></a>

发表评论 取消回复

电子邮件地址不会被公开。 必填项已用*标注