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

241
Vistas
How to prevent browser to follow href='#'

Hello recently I'm facing a new problem. I used a custom html code in the middle section of my website. After implement the html my website automatically go to that section after loading. I think this is the culprit:3

<div class="results" id="results">
   <a class="domain" href="#" id="domain">helloworld.com</a>
</div>

Here there is an hash tag that force browser to go to this particular section. That is to say I used "javascript:void(0)" instead of # but nothing improved. My question is how can I push browser to say header and not to follow that result id.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Simple use javascript It will changes hash in url from anything to your required header

Make sure your header has the id attribute header.

window.location.hash = "header";
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can prevent the browser to follow a link (with an assigned href) with some simple JS code:

document.getElementById("domain").onclick(e => e.preventDefault());

Where e is the Click event object.

Although a javascript:void(0) on the href property should do the trick too.

You should probably also set the link's rel property to nofollow, like this:

<a class="domain" href="#" id="domain" rel="nofollow">helloworld.com</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