多显示器/双显示器系统上的window.open() - 窗口弹出的位置在哪里? [英] window.open() on a multi-monitor/dual-monitor system - where does window pop up?

查看:758
本文介绍了多显示器/双显示器系统上的window.open() - 窗口弹出的位置在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在多显示器系统上使用javascript window.open()时,如何控制弹出窗口打开的显示器或显示空间中的哪个位置?对我来说似乎失去控制,而且其行为也是随机的。

When using javascript window.open() on a multi-monitor system, how do you control which monitor, or where in the display space the popup opens? It seems out of control to me and otherwise random in it's behavior.

推荐答案

window.open双屏搜索结果透露了这个花哨的金块: Dual Monitors and Window.open

Result of "window.open dual-screen" search revealed this fancy nugget: Dual Monitors and Window.open


当用户点击使用
window.open打开新窗口的链接时。使窗口显示在同一窗口上监视为'
父母。

"When the user clicks on a link that opens a new window using window.open. Make the window appear on the same monitor as its' parent."



// Find Left Boundry of the Screen/Monitor
function FindLeftScreenBoundry()
{
    // Check if the window is off the primary monitor in a positive axis
    // X,Y                  X,Y                    S = Screen, W = Window
    // 0,0  ----------   1280,0  ----------
    //     |          |         |  ---     |
    //     |          |         | | W |    |
    //     |        S |         |  ---   S |
    //      ----------           ----------
    if (window.leftWindowBoundry() > window.screen.width)
    {
        return window.leftWindowBoundry() - (window.leftWindowBoundry() - window.screen.width);
    }

    // Check if the window is off the primary monitor in a negative axis
    // X,Y                  X,Y                    S = Screen, W = Window
    // 0,0  ----------  -1280,0  ----------
    //     |          |         |  ---     |
    //     |          |         | | W |    |
    //     |        S |         |  ---   S |
    //      ----------           ----------
    // This only works in Firefox at the moment due to a bug in Internet Explorer opening new windows into a negative axis
    // However, you can move opened windows into a negative axis as a workaround
    if (window.leftWindowBoundry() < 0 && window.leftWindowBoundry() > (window.screen.width * -1))
    {
        return (window.screen.width * -1);
    }

    // If neither of the above, the monitor is on the primary monitor whose's screen X should be 0
    return 0;
}

window.leftScreenBoundry = FindLeftScreenBoundry;




现在编写代码,现在可以使用window.open在父窗口打开的监视器上打开
窗口。

Now that the code is written, you can now use window.open to open a window on the monitor the parent window is on.



window.open(thePage, 'windowName', 'resizable=1, scrollbars=1, fullscreen=0, height=200, width=650, screenX=' + window.leftScreenBoundry() + ' , left=' + window.leftScreenBoundry() + ', toolbar=0, menubar=0, status=1');

如果它成功允许您在启动文档的同一屏幕上打开弹出窗口,那么类似的努力应该能够修改它以表现不同。

If it successfully allows you to open a popup on the same screen as the document launching it, then with similar effort one should be able to modify it to behave differently.

请注意,正如代码长度所暗示的那样,没有用于理解多个监视器的内置函数jquery / javascript / browsers,只是双屏桌面只是一个放大的单个笛卡尔平面,而不是两个不连续的平面。

Note that, as the length of code implies, there is no built-in function for understanding multiple monitors in jquery/javascript/browsers, only that the dual-screen desktop is simply an enlarged single cartesian plane instead of two discrete planes.

更新

这个链接已经死了。使用这个waybackmachine链接

The link is dead. Use this waybackmachine link

这篇关于多显示器/双显示器系统上的window.open() - 窗口弹出的位置在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆