function openwindow( url, winName, width, height)
{
xposition=0; yposition=0;
if ((parseInt(navigator.appVersion) >= 4 ))
{
xposition = (screen.width - width) / 2;
yposition = (screen.height - height) / 2;
}
theproperty= "width=" + width + ","
+ "height=" + height + ","
+ "location=0,"
+ "menubar=0,"
+ "resizable=0,"
+ "scrollbars=yes,"
+ "status=0,"
+ "titlebar=0,"
+ "toolbar=0,"
+ "location=no,"
+ "status=no,"
+ "screenx=" + xposition + "," //for Netscape
+ "screeny=" + yposition + "," //for Netscape
+ "left=" + xposition + "," //for IE
+ "top=" + yposition; //for IE
window.open( url,winName,theproperty );
}
{
xposition=0; yposition=0;
if ((parseInt(navigator.appVersion) >= 4 ))
{
xposition = (screen.width - width) / 2;
yposition = (screen.height - height) / 2;
}
theproperty= "width=" + width + ","
+ "height=" + height + ","
+ "location=0,"
+ "menubar=0,"
+ "resizable=0,"
+ "scrollbars=yes,"
+ "status=0,"
+ "titlebar=0,"
+ "toolbar=0,"
+ "location=no,"
+ "status=no,"
+ "screenx=" + xposition + "," //for Netscape
+ "screeny=" + yposition + "," //for Netscape
+ "left=" + xposition + "," //for IE
+ "top=" + yposition; //for IE
window.open( url,winName,theproperty );
}
本文详细解析了JavaScript函数openwindow的实现逻辑,包括如何根据浏览器窗口大小动态调整打开新窗口的位置,适用于创建弹窗、轻应用等场景。
777

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



