Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

You need target="_blank" for this.

<a href="www.google.com" target="_blank">Click</a>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda