Open link in the browser with electron doesen't work

Viewed 25

I tried this BUT it doesn't work because my link is a div. Here is my JS:

document.addEventListener('click', function (event) {
  if (event.target.tagName === 'A' && event.target.href.startsWith('http')) {
    event.preventDefault()
    shell.openExternal(event.target.href)
  }
})

Works with this HTML:

<a style="display:block;color:white;text-decoration:none;" href="https://discord.com/">Test</a>

Does not work with:

<a style="display:block;color:white;text-decoration:none;" href="https://discord.com/"><div class="socialoutline"><img style="width:35px;position:relative;left:7px;top:9px;"src="assets/images/logo/social/discord.svg">&#8195;&#8196;Discord</div></a>
0 Answers
Related