简体   繁体   中英

Open URL with Electron in non-default Browser

I am using Electron to try and open a URL. I know I can do something like

const { shell } = require('electron')

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

to open the URL in the default browser.

Is there any way to do this in the non-default browser? For example, if I want to open a link to the Edge Store, but my default browser is Chrome, can I do something like

const { shell } = require('electron')

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

You're not going to be able to do that with just default shell , because as far as I know it relies entirely on user system defaults, but there are existing npm packages like open that will give you this functionality, with something like:

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

Their documentation will walk you through how to get this working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM