【问题标题】:window.open() opens a new electron browser window instead of native browser windowwindow.open() 打开一个新的电子浏览器窗口而不是原生浏览器窗口
【发布时间】:2020-05-11 06:30:53
【问题描述】:

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

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

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

应用程序会打开一个新的电子浏览器窗口。我希望窗口在本机浏览器窗口(chrome、firefox、internet explorer 等)中打开。这可以在电子应用程序中实现吗?

【问题讨论】:

    标签: html angular electron


    【解决方案1】:

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

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

    阅读以了解更多信息:

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

    【讨论】:

    • 它现在按预期打开了!
    猜你喜欢
    • 2011-02-18
    • 2018-05-20
    • 1970-01-01
    • 2015-04-02
    • 2018-07-28
    • 1970-01-01
    • 1970-01-01
    • 2016-11-29
    • 1970-01-01
    相关资源
    最近更新 更多