Skip to content

Instantly share code, notes, and snippets.

@vojtatranta
Last active December 25, 2017 22:30
Show Gist options
  • Save vojtatranta/e62e13e3974ad7251b394aa7769caff4 to your computer and use it in GitHub Desktop.
Save vojtatranta/e62e13e3974ad7251b394aa7769caff4 to your computer and use it in GitHub Desktop.
open url in browser from electron
const electron = require('electron')
const BrowserWindow = electron.BrowserWindow
const shell = electron.shell
const window = new BrowserWindoe({...})
function handleRedirect(e, url) {
e.preventDefault()
if (url !== mainWindow.webContents.getURL()) {
shell.openExternal(url)
}
}
window.webContents.on('will-navigate', handleRedirect)
window.webContents.on('new-window', handleRedirect)
Copy link

ghost commented Dec 25, 2017

https://s10.postimg.org/tq35furg9/screenshot_102.png

jaksi nefunguje,.. + sa mi nezdá to Windoe má asi (teda určite) byť Window

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment