六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 68|回复: 0

根据分辨率让window.open的窗口居中

[复制链接]

升级  83.33%

49

主题

49

主题

49

主题

秀才

Rank: 2

积分
175
 楼主| 发表于 2013-2-7 15:11:57 | 显示全部楼层 |阅读模式
var   popwin;
 if(screen.width=="640")  
   {  
   popwin =  window.open("s1.html","name","resizable=yes,scrollbars=no,menubar=no,toolbar=no,width=450,height=400");
   }  
   else   if(screen.width=="800")  
   {  
     popwin =  window.open("s1.html","name","resizable=yes,scrollbars=no,menubar=no,toolbar=no,width=450,height=400");
   }  
   else   if(screen.width=="1024")  
   {  
     popwin =  window.open("s1.html","name","resizable=yes,scrollbars=no,menubar=no,toolbar=no,width=450,height=400");
   }  
 //重新设置窗口大小
 popwin.resizeTo("550","500");
 //网页正文全文宽
 pw = popwin.document.documentElement.scrollWidth-4;
 //网页正文全文高
 ph =  popwin.document.documentElement.scrollHeight-4;
 //移动窗口到中心位置
 popwin.moveTo((screen.width-pw)/2,(screen.height-ph)/2);
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表