Open new windows in external browser

When a user clicks a link, this opens the link in a new external browser
and not in a new nw window (without toolbar, download manager, etc.)
10.3.x-maintenance
Miguel Angel Mulero Martinez 2017-12-20 15:46:20 +01:00
parent bd1545484d
commit 4b7af1c951
1 changed files with 16 additions and 0 deletions

16
main.js
View File

@ -1,5 +1,21 @@
'use strict';
// Open new windows in external browser
try {
var gui = require('nw.gui');
//Get the current window
var win = gui.Window.get();
//Listen to the new window event
win.on('new-win-policy', function (frame, url, policy) {
gui.Shell.openExternal(url);
policy.ignore();
});
} catch (ex) {
console.log("require does not exist, maybe inside chrome");
}
$(document).ready(function () {
// translate to user-selected language
localize();