From 3c20f55e8561151f6ea75c39cb329a98aed794f6 Mon Sep 17 00:00:00 2001 From: Ramiro Saenz Date: Tue, 5 Jul 2016 20:23:11 -0300 Subject: [PATCH] Open Rambox links in external browser. Links inside Rambox, and not inside Webviews. Like GitHub, Donate, etc. --- electron/main.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/electron/main.js b/electron/main.js index 9f82a35c..8ed3d272 100644 --- a/electron/main.js +++ b/electron/main.js @@ -134,8 +134,17 @@ function createWindow () { mainWindow.on('page-title-updated', (e, title) => updateBadge(title)); + // Open links in default browser + mainWindow.webContents.on('new-window', function(e, url, frameName, disposition, options) { + const protocol = require('url').parse(url).protocol; + if (protocol === 'http:' || protocol === 'https:' || protocol === 'mailto:') { + e.preventDefault(); + shell.openExternal(url); + } + }); + mainWindow.webContents.on('will-navigate', function(event, url) { - //event.preventDefault(); + event.preventDefault(); }); // Emitted when the window is closed.