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

238
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 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