我正在寻找有关如何使弹出窗口取决于屏幕分辨率的解决方案。我正在使用javascript,因为这是必需条件。
调用以下函数时,我的弹出窗口将打开:
function openContent("mypage.htm);
我正在尝试找出并具有以下内容:
function openContent(url) {
var width = 900;
var height = 900;
var left = screen.width/4;
var top = 0;
var win;
alert("Screen Height: " + screen.height);
alert("Screen Width: " + screen.width);
if (screen.width < 900) {
width = screen.width - 100;
left = screen.width - width ;
}
if (screen.height <= 900) {
height = screen.height - 70;
width = width - 100;
}
win = window.open(url, 'content', "toolbar=no, titlebar=no, status=no, scrollbars=yes, resizable=no, top=" + top + ", left=" + left + ", width=" + width + ", height=" + height + "\"");
win.focus();
}
我在工作地点有两个台式机。当尝试使用不同的分辨率时,此页面有时会分为2个桌面。
此外,当窗口的某个部分的高度大于屏幕的高度时,该部分将被隐藏。我也在考虑笔记本电脑用户。他们还能看到整个页面吗?>
什么是好的解决方案?
谢谢
我正在寻找有关如何使弹出窗口取决于屏幕分辨率的解决方案。我正在使用javascript,因为这是一项要求。当以下功能为...
我相信此答案将帮助您,即使它最初涵盖了另一个方面:
不需要太多代码,只需执行以下代码: