window.open()打开一个新的电子浏览器窗口,而不是本机浏览器窗口

时间:2020-01-24 23:00:17

标签: html angular electron

我的电子桌面应用程序将角度应用程序加载到浏览器窗口中。该有角度的应用程序具有一个应该打开一个新网站的按钮(以google.com为例)。当我使用以下代码时...

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

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

该应用程序将打开一个新的电子浏览器窗口。我希望在本机浏览器窗口(chrome,firefox,Internet Explorer等)中打开该窗口。在电子应用程序中可以做到这一点吗?

1 个答案:

答案 0 :(得分:1)

根据文档,您可以使用以下代码在OS默认浏览器上打开链接

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

阅读以获取更多信息:

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

相关问题