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

277
Views
How to prevent jumping to top of the page when clicking on a link?

I have been stuck on how to prevent jumping to the top of the page when clicking on a link that has parsing PHP data.

I have tried so many things, like preventDefault or return false or putting "/" at the end, but unfortunately with no success. Observation: this is linking to the same page, but is sending a php value.

The link looks like this:

<a id="chatLink" href="explore.php?user_id=<?php echo $row['unique_id']?>"
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

First you need to store scrollValue before leaving page:

window.onscroll = e => localStorage.setItem('scrollTop', document.body.scrollTop);

Then, when new page load, set scroll back:

window.onload = e => {
    const scrollTop= localStorage.getItem('scrollTop');
    document.body.scrollTop = scrollTop;
}
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!