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);
本文介绍了一种根据屏幕宽度自动调整弹窗大小并居中的JavaScript实现方法,适用于多种设备分辨率。
4435

被折叠的 条评论
为什么被折叠?



