1

For demonstrations: Let's say I had this:

<div id=top>
<p>Placeholder 1</p>
</div>
<div id=mid>
<p>Placeholder 2</p>
</div>
<div id=bottom>
<p>Placeholder 3</p>
</div>

<div>
<a href="#top">Jump to Top</a>
</div>

If I were to press "Jump to Top" it would do what I want it to do, jump to a specific area. But it would change the URL to www.your-domain-whatever.com/page#top. How could I get the same functionality but keep the URL as www.your-domain-whatever.com/page instead of www.your-domain-whatever.com/page#top? I've looked around, can't seem to find something that helps

jasonhe
  • 134
  • 12
  • 1
    Does this answer your question? [How to scroll HTML page to given anchor?](https://stackoverflow.com/questions/3163615/how-to-scroll-html-page-to-given-anchor) – BadZen Jun 20 '21 at 22:43
  • (the accepted answer is maybe not the one you want there, however?) – BadZen Jun 20 '21 at 22:44

1 Answers1

0

Use element.scrollIntoView()

var element = document.getElementById("top");
element.scrollIntoView();

The documentation for it is found here.

JCollier
  • 1,102
  • 2
  • 19
  • 31