From 5e988626fd8682ca35f7f4cbabe4dafa4cc4609c Mon Sep 17 00:00:00 2001 From: Manolis Mandrapilias <70536101+moneymanolis@users.noreply.github.com> Date: Wed, 15 Mar 2023 12:16:15 +0100 Subject: [PATCH] Bugfix: replace deprecated new-window with setWindowOpenHandler (#2293) Co-authored-by: k9ert --- pyinstaller/electron/main.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pyinstaller/electron/main.js b/pyinstaller/electron/main.js index 86b15d0e9..8dc6242f4 100644 --- a/pyinstaller/electron/main.js +++ b/pyinstaller/electron/main.js @@ -364,10 +364,11 @@ function initMainWindow() { webPreferences }) - mainWindow.webContents.on('new-window', function(e, url) { - e.preventDefault(); - shell.openExternal(url); - }); + // Ensures that any links with target="_blank" or window.open() will be opened in the user's default browser instead of within the app + mainWindow.webContents.setWindowOpenHandler(({ url }) => { + shell.openExternal(url) + return { action: 'deny' } + }) mainWindow.on('close', function (event) { if(platformName == 'win64') {