feat: #20442 adds fiddle for opening external links and the pro version of opening all outbound links (#20763)
This commit is contained in:
parent
97959b5e5c
commit
09533e77da
3 changed files with 113 additions and 0 deletions
|
@ -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)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue