【发布时间】:2014-05-20 20:51:54
【问题描述】:
我正在寻找有关如何使我的弹出窗口取决于屏幕分辨率的解决方案。 我正在使用 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 popupwindow screen-resolution