Skip to content

Commit f1cf317

Browse files
authored
Merge pull request #95 from McGiverGim/bf-open_links_new_window
From CF: Open links in external browser
2 parents 266b56f + 7cfcf94 commit f1cf317

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2+
openLinksInExternalBrowserByDefault();
3+
14
$(document).ready(function () {
25
// translate to user-selected language
36
localize();
@@ -65,3 +68,21 @@ function getManifestVersion(manifest) {
6568

6669
checkForConfiguratorUpdates();
6770

71+
function openLinksInExternalBrowserByDefault() {
72+
try {
73+
var gui = require('nw.gui');
74+
75+
//Get the current window
76+
var win = gui.Window.get();
77+
78+
//Listen to the new window event
79+
win.on('new-win-policy', function (frame, url, policy) {
80+
gui.Shell.openExternal(url);
81+
policy.ignore();
82+
});
83+
} catch (ex) {
84+
console.log("require does not exist, maybe inside chrome");
85+
}
86+
}
87+
88+

0 commit comments

Comments
 (0)