Skip to content

Commit

Permalink
Bugfix: replace deprecated new-window with setWindowOpenHandler (#2293)
Browse files Browse the repository at this point in the history
Co-authored-by: k9ert <[email protected]>
  • Loading branch information
moneymanolis and k9ert authored Mar 15, 2023
1 parent 6a4829e commit 5e98862
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pyinstaller/electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down

0 comments on commit 5e98862

Please sign in to comment.