Abrir links externos em uma nova guia sem jQuery
Qual é a melhor maneira de abrir todos os links externos (URLs que não correspondem ao domínio atual) em uma nova guia usando JavaScript, sem usar jQuery?
Aqui está a jQuery que estou usando atualmente:
// Open external links in new tab
$('a[href^=http]').click(function () {
var a = new RegExp('/' + window.location.host + '/');
if (!a.test(this.href)) {
window.open(this.href);
return false;
}
});