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

179
Visualizações
Add url to href on <a> tag but do not want to reload behavior

The following code opens the anchor tag on a new window However, I do not want to reload the parent page. And also I want to have the ability to Open in a new tab on mouse right click (image below)

enter image description here

If I use href = {'javascript:'} it prevents the parent page from reloading however, when clicked on "Open in a new Tab", it opens on a new tab but url becomes about:blank#blocked

const handleClick = () => {
      window.open(
        href,
        'newwindow',
        `width=${window.outerWidth * 0.5}, height=${
          window.outerHeight
        }, left = ${window.outerWidth * 0.25} `
      );
      return false;
  };

<a href = {href} onClick = {handleClick}> This is Url </a>

Desired result:

  • By default, open in a new window.
  • Prevent parent window from refreshing.
  • Have ability to open on new tab on right click.
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

To open the link in a new window or a new tab, you can use the target attribute in your anchor tag i.e. <a href="https://example.com" target="_blank">...</a>

about 4 years ago · Juan Pablo Isaza Relatório

0

You need target="_blank" for this.

<a href="www.google.com" target="_blank">Click</a>
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