Kode_12
Kode_12

Reputation: 4828

window.open() opens a new electron browser window instead of native browser window

My electron desktop app loads an angular app into a browser window. That angular app has a button that should open a new website (lets say google.com as an example). When I use the following code...

<button (click)="openNew()">Open a new window</button>

openNew() {
  window.open('www.google.com')
}

the app opens a new electron browser window. I want the window to open in a native browser window (chrome, firefox, internet explorer, etc). Can this be possible within an electron app?

Upvotes: 1

Views: 682

Answers (1)

Ahmet Zeybek
Ahmet Zeybek

Reputation: 1224

Based on documentation, you can open links on OS default browser with code below

const { shell } = require('electron')
shell.openExternal('https://github.com')

Read for further information:

https://www.electronjs.org/docs/api/shell#shellopenexternalurl-options

Upvotes: 1

Related Questions