- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
嗨,我有一个使用 NW.JS 和 angularjs 的应用程序。但问题是,我想打开一个新窗口(从应用程序内加载新页面),而不从主窗口的菜单继承菜单栏。这在nwjs中可能吗?此外,每次我单击主窗口菜单栏中触发新窗口打开的菜单项时,它总是打开新窗口。我怎样才能防止这种情况发生?我的意思是,当我已经打开新窗口时,应用程序应该避免再次打开它,除非它已经关闭。
在我的index.html
var menu = new nw.Menu({ type: 'menubar' });
var submenu = new nw.Menu();
submenu.append(new nw.MenuItem({
label: 'Exit',
click: function(){
nw.App.quit();
}
}));
menu.append(new nw.MenuItem({
label: 'File',
submenu: submenu
}));
menu.append(new nw.MenuItem({
label: 'New Page',
click: function(){
nw.Window.open('index.html#/new_page')
}
}));
nw.Window.get().menu = menu;
最佳答案
当打开新窗口时,您使用的是相同的 html 文件,其中包含创建菜单栏的代码,因此显然也会为弹出窗口创建菜单栏,您需要为弹出窗口使用不同的 html 文件。
下面是完整版本的代码,如果它不适合您,请告诉我
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Demo</title>
<script type="text/javascript">
//var win = nw.Window.get();
//win.showDevTools();
var menu = new nw.Menu({ type: 'menubar' });
var submenu = new nw.Menu();
submenu.append(new nw.MenuItem({
label: 'Exit',
click: function(){
nw.App.quit();
}
}));
menu.append(new nw.MenuItem({
label: 'File',
submenu: submenu
}));
menu.append(new nw.MenuItem({
label: 'New Page',
click: function(){
console.log('open new page');
var parentWin = window;
if(parentWin.localStorage.getItem('child_open')) {
console.log('child window is already open');
return;
}
nw.Window.open('home.html#new_page', {}, function(win) {
parentWin.localStorage.setItem('child_open', true);
win.on('closed', function() {
parentWin.localStorage.removeItem('child_open');
});
});
}
}));
nw.Window.get().menu = menu;
</script>
</head>
<body>
</body>
</html>
home.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Inner Window</title>
</head>
<body>
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br />
<p id="new_page"> New page section </p>
</body>
</html>
关于javascript - 在 NW.js 中打开没有菜单栏的新窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41488348/
随着 Chrome 网上应用店应用程序即将停用,我已经成功地将我的应用程序转换为 nw.js 我对它的简单性和第一次运行的方式感到惊讶。我遇到的唯一棘手的事情是如何让我的应用程序图标在 mac 上显示
我想在一个世界中构建多个随机子图。因为,一般来说,子图的数量是不固定的,我不想为每个子图使用不同的品种。到目前为止,我对“手工”随机网络使用了一种非常粗鲁的方法(见下文),将“我的组”变量分配给海龟。
我知道 nw.js 通常是为了在客户端加载 html,但它也可以指向一个网站并显示吗?当我将 package.json 中的“main”值设置为 google.com 之类的值时,它不起作用。 我正在
在 nwjs 中构建 Web 应用程序会导致无法访问位于程序目录中的文件(以及 app.nw 文件),并且将所有文件添加到 nw 包中并不是一个好主意,因为某些文件可能需要在运行时通过 IO 进行更改
如果这是一个愚蠢的问题,我预先道歉。 当调用 nw:weighted-path-to 时,会返回一个链接列表,描述起始海龟和目标海龟之间的最短路径。 类似地,调用 nw:turtles-on-weig
我原以为 Node Webkit 会让打包并作为单个可执行文件添加到 Windows 变得简单,但它似乎并没有,他们建议使用 https://github.com/evshiron/nwjs-buil
我觉得我错过了一些简单的东西。 我正在 nw.js 中开发一个“托盘”应用程序。为此,我将 "main" 设置为 package.json 中的 "main.js" 文件。在 main.js 中,我实
稍微简化一下,NW.js和Electron包含浏览器(Webkit,Chromium或其他)的一部分,并结合了JavaScript引擎(node.js,io.js或其他)。 我的问题是:里面有多少份V
在我的主脚本中: var renderer = require('./templates/renderTemplates.js'); function show(json){ renderer
我正在尝试使用 module.exports()在我的 NW.js 应用程序中创建一个新模块。 我有两个正在使用的文件: 索引.js const gkm = require('gkm'); //Thi
我很感兴趣,当我处于控制台模式时,如何在 emacs 中调整拆分窗口的大小? 我打开我的文件: emacs myfilename.txt -nw 现在,当我将窗口拆分为: C-x 2 或者 C-x 3
我的应用程序是使用占位符构建的,单击“加载”时会直接读取文件。 Load showthefile() 执行一些操作,然后调用... var keyMapLoc = '\\path\\to\\file.
我正在将 NW.js v0.12.3 迁移到新的 NW.js v0.17.3。在我的旧应用程序中,我曾经打开一个窗口来显示来电通知。如果用户接听电话或挂断电话,我会根据特殊的事件监听器关闭窗口。 这是
下面的代码可以使用F11热键,让浏览器窗口全屏,如何实现第二次按F11热键,恢复原来的窗口大小? nw.App.registerGlobalHotKey(new nw.Shortcut({
环境 NW.js v0.12.3(32 位) Windows 8 Webchimera.js (播放器)VLC 构建 (2.2.1) require-new 问题 新窗口从父窗口打开。 Webchim
我在使用 nw.js 时遇到了一些问题。我已经“谷歌化”了很多天(几周),但我找不到任何解决方案。因此,我使用 nw.js 作为客户端来连接到内部服务器。它的工作方式就像一个经典的网站。我们可以使用网
我正在使用 Node Webkit 创建桌面应用程序。我现在需要创建一个可执行文件,因此安装了以下文件:https://github.com/nwjs/nw-builder 我很难理解说明,尤其是命令
我需要从包围地面叠加层的矩形中获取 NW LatLng。使用 mOverlay.getBounds() 将使我在旋转之前得到我需要的点(getBounds 忽略旋转)。 这是地面叠加层,我需要的确切
讨论 NetWeaver 7.4 (CD261) 中新的 ABAP 编程功能的 SAP 官方演示文稿对表表达式进行了大量讨论,替换了从内部表读取的旧语法: READ TABLE lt_aufk INT
在我的 NW.js 应用程序中,我将一些数据存储在本地存储中。现在我想删除应用程序和本地存储数据。我将应用程序移至垃圾箱并清理它。此外,我删除了与位于 /Users//Library/Caches/
我是一名优秀的程序员,十分优秀!