Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html anchor links

Tags:

html

anchor

I want there to be anchor links on a webpage where when I click on the link, it brings me to a certain part of the webpage.

However, when the user click the back page button, it is now bringing the user to the previous part of the page, instead of the previous page.

How should I implement the link so that it does bring the user to the previous page instead of the previous part of a page?

<a href="#some part">link</a>
like image 711
SuperString Avatar asked Feb 24 '23 10:02

SuperString


1 Answers

I wonder if you could do something like what is described in the top answer of this post. Put the following into the 'onclick' of your anchor, and it'll scroll to your div of choice, without changing the URL (and hence preserving back-button functionality).

document.getElementById('youridhere').scrollIntoView(); 

Don't forget to take out the "href=#somepart".

like image 89
dizzwave Avatar answered Mar 11 '23 01:03

dizzwave