I came up with this, after checking the solution from the previous answer.
mainWindow.webContents.on('new-window', function(e, url) {
e.preventDefault();
require('electron').shell.openExternal(url);
});
According to the electron spec, new-window
is fired when external links are clicked.
NOTE: Requires that you use target="_blank"
on your anchor tags.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…