Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

233
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!