弹出页面的javascript,自动居中
function openWin(u, w, h) {
var l = (screen.width - w) / 2;
var t = (screen.height - h) / 2;
var s = 'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l;
s += ', toolbar=no, scrollbars=no, menubar=no, location=no, resizable=no';
open(u, 'result', s);
}
u:url
w:弹出页面宽度
h:弹出页面高度
本文介绍了一种使用JavaScript实现的弹出窗口自动居中的方法。通过计算屏幕尺寸与弹窗大小的比例,调整弹窗的位置参数,使得弹出窗口无论在何种分辨率下都能保持在屏幕中央。此方法适用于需要快速实现窗口居中功能的场景。
159

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



