Skip to content

Instantly share code, notes, and snippets.

@ramingar
Created January 14, 2019 15:32
Show Gist options
  • Save ramingar/f3c3b9f47f3fe660c5b6ff04883eae2c to your computer and use it in GitHub Desktop.
Save ramingar/f3c3b9f47f3fe660c5b6ff04883eae2c to your computer and use it in GitHub Desktop.
Abrir una url de un <a> en el navegador por defecto #electron #anchor #browser

Fuente: electron/electron#1344 (comment)

En el main index.html

// index.html

// Open all links in external browser
let shell = require('electron').shell
document.addEventListener('click', function (event) {
  if (event.target.tagName === 'A' && event.target.href.startsWith('http')) {
    event.preventDefault()
    shell.openExternal(event.target.href)
  }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment