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

现在有一个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级讲师

全部回复(1)
左手右手慢动作

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

打开(url[, 选项])

打开一个新窗口并在其中加载网址,您可以在窗口中指定额外的选项。可以使用 Manifest 格式的所有窗口子字段。从 v0.4.0 开始,布尔字段 new-instance 可用于启动新的 Node 实例(webkit 进程)。从v0.9.0和0.8.5开始,inject-js-start和inject-js-end字段可以用来注入javascript文件,参见Manifest格式。

从 v0.7.3 开始,打开的窗口默认不聚焦。这是跨平台统一行为的结果。如果你想让它默认聚焦,可以在选项中将 focus 设置为 true。

雷雷
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板