I am creating an app using electron and angular2. I want to provide a help link which I want to open in external (default) browser of the user. How to do this?
Asked
Active
Viewed 2,539 times
3 Answers
3
In electron it's actually pretty straight forward to open any link in your default browser. You just need to import/require the shell module from electron.
import { shell } from 'electron';
shell.openExternal('https://example.com');
if your are not using ES6 just replace the import with const { shell } = require('electron');

Horst
- 407
- 5
- 17
-
angular2 is throwing error "Cannot find module 'electron'" – Mohd Shahid Apr 06 '17 at 13:52
-
@MohammadShahid seems like Angular 2 overrides require/import. Just follow this guide and you should be good to go: http://stackoverflow.com/a/37327006/2004682 – Horst Apr 06 '17 at 16:00
-
How to open it in a specific browser, exaple chrome and not my default explorer? – almightysosa Dec 27 '19 at 10:27
0
You can make it using nodejs and command line, something like this.
var exec = require('child_process').exec;
exec('start /max chrome.exe --incognito --app=' + url, function (error, stdout, stderr) {
if (error !== null) {
console.log('exec error: ' + error);
}
});
In this case url
will be what you want to open. And here i'm opening Chrome. But if you want to open the predeterminate brownser, just put something like this.
var exec = require('child_process').exec;
exec('start /max ' + url, function (error, stdout, stderr) {
if (error !== null) {
console.log('exec error: ' + error);
}
});

Paulo Galdo Sandoval
- 2,173
- 6
- 27
- 44
0
I got solution here
https://stackoverflow.com/a/42512480/848556
I fixed it by using ngx-electron
thanks

Community
- 1
- 1

Mohd Shahid
- 1,538
- 2
- 33
- 66