“window.open 双屏”搜索结果显示了这个花哨的金块:Dual Monitors and 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/browsers 中没有内置功能可以理解多个显示器,只是双屏桌面只是一个放大的单个笛卡尔平面而不是两个离散平面.
更新
链接已失效。使用this waybackmachine link