【问题标题】:How to make a pop up window resolution independent如何使弹出窗口分辨率独立
【发布时间】: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


    【解决方案1】:

    我相信这个答案会对您有所帮助,即使它最初涵盖了另一个方面:

    https://stackoverflow.com/a/16861050/2479028

    【讨论】:

      【解决方案2】:

      不需要这么多代码,只需执行以下代码即可:

      alert("Text here");
      

      会弹出一个窗口。

      如果您需要帮助,请告诉我。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-09-22
        • 1970-01-01
        • 2010-09-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多