In my app, I need to on full load, detect if is Electron, then fire a custom event. How to achieve it? Thanks in advance.
Asked
Active
Viewed 1,941 times
4
-
Possible duplicate of [How to set electron UserAgent](http://stackoverflow.com/questions/35672602/how-to-set-electron-useragent) – Sandy Gifford Apr 21 '17 at 18:48
2 Answers
9
I prefer this
// check if app is running inside the electron env or browser
var userAgent = navigator.userAgent.toLowerCase();
if (userAgent.indexOf(' electron/') == -1) {
// its not electron
}

www.amitpatil.me
- 3,001
- 5
- 43
- 61
0
if(process.versions.electron != 'undefined' && process.versions.electron != null){
//Custom event
}
I think is the most standard way of doing this.

Kyle Becker
- 1,360
- 12
- 20
-
Thank you! Can I introduce it inside a onload event? – dani 'SO learn value newbies' Apr 21 '17 at 18:49
-
-
-
@Plasmmer `if(process.versions.electron != 'undefined' && process.versions.electron != null){ //Custom event } else{//Do this if not electron}` – Kyle Becker Apr 21 '17 at 18:57