From ddfdeee5b069f5778b3fb57afd400da7483ade63 Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 8 Oct 2020 22:03:20 +0200 Subject: [PATCH] Open links with target="_blank" in a new window by default --- src/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index df64f71..873343e 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, protocol, session } = require('electron') +const { app, BrowserWindow, protocol, shell } = require('electron') const path = require('path') function createWindow () { @@ -11,6 +11,11 @@ function createWindow () { } }) + win.webContents.on('new-window', function(e, url) { + e.preventDefault(); + shell.openExternal(url); + }) + // The starting point of the app win.loadFile('./frontend/index.html') }