Open a new tab and redirect the current tab to another page in a JavaScript link [closed]

-4

I need to javascript a link that opens a page in a new tab and redirects the current page to another link.

    
asked by anonymous 26.02.2017 / 03:00

1 answer

1

HTML:

<a href="https://www.google.com.br" target="_blank" id="xx">abrir em nova janela</a>

JS:

document.getElementById('xx').addEventListener('click', function(){
  location.replace('https://pt.stackoverflow.com');
});
    
26.02.2017 / 03:50