Javascript 如何在nw.js中并排对齐两个窗口?

Javascript 如何在nw.js中并排对齐两个窗口?,javascript,nw.js,Javascript,Nw.js,这是我的密码 var height=window.screen.availHeight; var width=window.screen.availWidth; var scenarioId = selectedScenarioIds[0]; var url ='url'+scenarioId; width=(width/2); if (typeof process == "object") { nw.Window.open

这是我的密码

var height=window.screen.availHeight;
var width=window.screen.availWidth;
var scenarioId = selectedScenarioIds[0];
var url ='url'+scenarioId;
width=(width/2);
if (typeof process == "object") {                               
     nw.Window.open(url, {
         position: 'center',
         width: width,
         height: height,
         focus: true
    }); 
 }
scenarioId = selectedScenarioIds[1];
var url ='url'+scenarioId;
if (typeof process == "object") {
    nw.Window.open(url, {
        position: 'center',
        width: width,
        height: height,
        focus: true
                });
    }   
我想做的是打开两个窗口进行比较。上面的代码正在工作,但两个窗口正在一个接一个地打开,但我希望它一个接一个地打开。。实现这一点的方法是nw.js吗?
提前感谢….

那是因为你把它们都放在了中间!为什么不根据需要设置win.xwin.y属性,以便将它们并排放置?

这是因为它们都居中了!为什么不根据需要设置win.xwin.y属性,以便将它们并排放置?

您需要按所述更改窗口的位置。您可以通过
nw.Window.open
作为回调函数的第三个参数来操作打开的窗口

var width = window.screen.availWidth;
var halfWidth = width / 2 - 16; // Tested on Windows 8. Width of side borders: 8px.
var height = window.screen.availHeight;
var scenarioId = selectedScenarioIds[0];
var url ='url'+scenarioId;
if (typeof process == "object") {
    nw.Window.open(url, {
        position: 'center',
        width: halfWidth,
        height: height,
        focus: true
    }, function(win) {
        win.moveTo(0, 0);
    });
}
scenarioId = selectedScenarioIds[1];
url ='url'+scenarioId;
if (typeof process == "object") {
    nw.Window.open(url, {
        position: 'center',
        width: halfWidth,
        height: height,
        focus: true
    }, function(win) {
        win.moveTo(width, 0);
    });
}
在Windows 8.1上测试,其中窗口边框的宽度在两侧为
8px
,因此必须从
window.screen.availWidth/2
中减去它


要成功设置窗口的位置,它们的URL必须响应。

您需要如前所述更改窗口的位置。您可以通过
nw.Window.open
作为回调函数的第三个参数来操作打开的窗口

var width = window.screen.availWidth;
var halfWidth = width / 2 - 16; // Tested on Windows 8. Width of side borders: 8px.
var height = window.screen.availHeight;
var scenarioId = selectedScenarioIds[0];
var url ='url'+scenarioId;
if (typeof process == "object") {
    nw.Window.open(url, {
        position: 'center',
        width: halfWidth,
        height: height,
        focus: true
    }, function(win) {
        win.moveTo(0, 0);
    });
}
scenarioId = selectedScenarioIds[1];
url ='url'+scenarioId;
if (typeof process == "object") {
    nw.Window.open(url, {
        position: 'center',
        width: halfWidth,
        height: height,
        focus: true
    }, function(win) {
        win.moveTo(width, 0);
    });
}
在Windows 8.1上测试,其中窗口边框的宽度在两侧为
8px
,因此必须从
window.screen.availWidth/2
中减去它

要成功设置窗口的位置,其URL必须响应