【问题标题】:Open URL with Electron in non-default Browser在非默认浏览器中使用 Electron 打开 URL
【发布时间】:2020-11-27 06:04:36
【问题描述】:

我正在使用 Electron 尝试打开一个 URL。我知道我可以做类似的事情

const { shell } = require('electron')

shell.openExternal('https://github.com')

在默认浏览器中打开 URL。

有没有办法在非默认浏览器中做到这一点?例如,如果我想打开一个指向 Edge Store 的链接,但我的默认浏览器是 Chrome,我可以这样做

const { shell } = require('electron')

shell.openExternal('microsoft-edge:https://github.com')

【问题讨论】:

    标签: javascript google-chrome electron cross-browser microsoft-edge


    【解决方案1】:

    仅使用默认 shell 是无法做到这一点的,因为据我所知,它完全依赖于用户系统默认设置,但是现有的 npm 包(如 open)将为您提供此功能功能,例如:

    await open('microsoft-edge:https://github.com');

    他们的文档将指导您完成这项工作。

    【讨论】:

      猜你喜欢
      • 2014-12-06
      • 1970-01-01
      • 2018-10-04
      • 1970-01-01
      • 2018-12-10
      • 1970-01-01
      • 2011-05-30
      • 2017-10-03
      • 2018-08-21
      相关资源
      最近更新 更多