Created
July 27, 2017 11:37
-
-
Save luizcarraro/2d04d83e66e3f03bef9b2e714ea8c0d7 to your computer and use it in GitHub Desktop.
ELECTRON: Open link in external default OS browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('body').on('click', '#messages-view a', (event) => { | |
event.preventDefault(); | |
let link = event.target.href; | |
require("electron").shell.openExternal(link); | |
}); |
@IzzleNizzle Thanks so much!
Here's another one without jQuery
const { shell } = require("electron")
document.body.addEventListener('click', event => {
if (event.target.tagName.toLowerCase() === 'a' && event.target.protocol != 'file:') {
event.preventDefault();
shell.openExternal(event.target.href);
}
});
Hi!
where should I put this in my app? I mean, the file?
same question, where?
Helps me to understand, thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you !