feat: #20442 adds fiddle for opening external links and the pro version of opening all outbound links (#20763)

This commit is contained in:
Alan Ionita 2019-11-13 05:46:35 +00:00 committed by Cheng Zhao
parent 97959b5e5c
commit 09533e77da
3 changed files with 113 additions and 0 deletions

View file

@ -0,0 +1,21 @@
const { shell } = require('electron')
const exLinksBtn = document.getElementById('open-ex-links')
exLinksBtn.addEventListener('click', (event) => {
shell.openExternal('http://electron.atom.io')
})
const OpenAllOutboundLinks = () => {
const links = document.querySelectorAll('a[href]')
Array.prototype.forEach.call(links, (link) => {
const url = link.getAttribute('href')
if (url.indexOf('http') === 0) {
link.addEventListener('click', (e) => {
e.preventDefault()
shell.openExternal(url)
})
}
})
}