Skip to content

Commit 5e98862

Browse files
moneymanolisk9ert
andauthored
Bugfix: replace deprecated new-window with setWindowOpenHandler (#2293)
Co-authored-by: k9ert <k9ert@gmx.de>
1 parent 6a4829e commit 5e98862

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pyinstaller/electron/main.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,11 @@ function initMainWindow() {
364364
webPreferences
365365
})
366366

367-
mainWindow.webContents.on('new-window', function(e, url) {
368-
e.preventDefault();
369-
shell.openExternal(url);
370-
});
367+
// Ensures that any links with target="_blank" or window.open() will be opened in the user's default browser instead of within the app
368+
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
369+
shell.openExternal(url)
370+
return { action: 'deny' }
371+
})
371372

372373
mainWindow.on('close', function (event) {
373374
if(platformName == 'win64') {

0 commit comments

Comments
 (0)