簡體   English   中英

如何在nw.js中並排排列兩個窗口?

[英]How to align two windows side by side in 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(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屬性,以便它們並排放置?

你需要改變窗口的位置,如@Coder所說。 你可以通過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必須響應。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM