Skip to content

Instantly share code, notes, and snippets.

@ahnerd
Created August 3, 2016 21:47
Show Gist options
  • Save ahnerd/1dc79f0a5f31ae5200223e3cc589f6fe to your computer and use it in GitHub Desktop.
Save ahnerd/1dc79f0a5f31ae5200223e3cc589f6fe to your computer and use it in GitHub Desktop.
How to open a link in default browser with electron shell (http://www.techiediaries.com)
var shell = require('electron').shell;
document.addEventListener('DOMContentLoaded',function(){
var el = document.querySelector('#mylink');
el.addEventListener('click',function(event){
event.preventDefault();
shell.openExternal(this.href);
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment