0

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?

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

3 Answers3

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
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