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

78
Views
My location.href is overriding another function of mine

I have a location.href code added to identify the section of the page the user is viewing in the URL (www.example.com/#section1, www.example.com/#section2 etc.)

  document.getElementById('link_no' + (i + 1)).classList.add('active-link');
        let currentLocation = location.href;
        currLocationArray = currentLocation.split("#");
        currentLocation = currLocationArray[0];
        currentLocation += `#section${i+1}`;
        
        location.href = currentLocation;
// scroll section
let sectionOfI = document.getElementById(`section${i+1}`);
        let scrollArea = getOffset(sectionOfI);
          scrollEventNew(scrollArea.top,e);

but it's messing up the smooth scroll of my JS built scroll function



function scrollEventNew(y , event) {
      window.scrollTo({
        left: 0,
        top: y,
        behavior: 'smooth'
    })  
    }

is there a way to keep both codes without commenting out my location.href?
I can't opt for a CSS smooth scroll either.

about 4 years ago · Juan Pablo Isaza
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!