“window.open 双屏”搜索的结果揭示了这个奇特的金块:双显示器和 Window.open
“当用户单击打开新窗口的链接时,使用
窗口.打开。使窗口与其所在的显示器显示在同一台显示器上
家长。”
// 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来打开一个
父窗口所在的监视器上的窗口。
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');
如果它成功地允许您在启动它的文档所在的同一屏幕上打开弹出窗口,那么通过类似的努力,人们应该能够修改它以使其表现不同。
请注意,正如代码长度所暗示的那样,jquery/javascript/浏览器中没有用于理解多个显示器的内置函数,只是双屏桌面只是放大的单个笛卡尔平面而不是两个离散的平面。
Update
链接已失效。使用这样返回机器链接