Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

196
Visualizações
How to make HTML Anchor link to do 2 different things?

How can I make an anchor do two things,

  1. Bring the user down the same page
  2. Open a new tab to another link.
<a href="http://www.example.com/#test" target="_blank" onclick="window.open('http://www.example.com'); window.open('http://www.example.com');">TEST</a>
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can achieve this by having two events in one single element, e.g:

        document.getElementById("test").addEventListener("click",function(){
            window.open('http://www.yahoo.com', '_self');
            window.open('http://www.google.com', '_blank');


        })
<a id="test">click me</a>

So the first link will open in the same page, and the other one will open on a blank new page.

about 4 years ago · Juan Pablo Isaza Relatório

0

you can control your link behaviour by adding listener on it and prevent default action, example:

const link = document.querySelector("a"); // it would be good to add some id to your html anchor tag
const url = "http://www.example.com/#BINANCVIDEO"; // tab url you want to open
    link.addEventListener("click", event => {
      event.preventDefault(); // stop default redirect 
      window.scrollTo(0,document.body.scrollHeight); // scroll user to bottom
      window.open(url, '_blank'); // you can add .focus() to this line if you prefer that
    });
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda