node.js - nwjs有没有API用来打开新的nw实例窗口
PHP中文网
PHP中文网 2017-04-17 11:36:53
0
1
700

现在有一个nw窗口a,需要使用API打开另外一个nw窗口b,且窗口b内可以调用nodejs及对窗口的操作的API。

package.json

{
  "name": "node-webkit menu demo",
  "main": "index.html",
  "version": 1.1,

  "window": {
    "show": false,
    "position": "center",
    "single-instance": false,
    "width": 500,
    "toolbar":true,
    "frame":true,
    "node-remote":"<local>",
    "height": 500
  }
}

打开子窗口

 function openChildWindow() {
    var url = "http://localhost:3900/file/1";

    var docWindowOptions = {
      "new-instance": true,
      "show_in_taskbar":true,
      //"toolbar":false,
      "show": true
    };
    require('nw.gui').Window.open(url,docWindowOptions)
  }
PHP中文网
PHP中文网

认证0级讲师

reply all(1)
左手右手慢动作

参考文档: https://github.com/nwjs/nw.js/wiki/Window#openurl-options

open(url[, options])

Open a new window and load url in it, you can specify extra options with the window. All window subfields in Manifest format can be used. Since v0.4.0, a boolean field new-instance can be used to start a new Node instance (webkit process). Since v0.9.0 and 0.8.5, inject-js-start and inject-js-end field can be used to inject a javascript file, see Manifest format .

Since v0.7.3 the opened window is not focused by default. It's a result of unifying behavior across platforms. If you want it to be focused by default, you can set focus to true in options.

var win = gui.Window.open('https://github.com', {
  position: 'center',
  width: 901,
  height: 127
});
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template