My website is quite extensive and contains numerous elements. There are times when I find myself wanting to navigate back and forth between different sections of the page.
I've noticed that some websites have a feature called a "page trail," which displays a list of the browsing history:
|page1>>|page2>>|page3>>|page4>>
with the last one representing the current page. If you click on page5
, it opens up page 5 with the updated trail:
|page2>>|page3>>|page4>>|page5>>
Now, if you go back to page4
, the trail would show:
|page2>>|page3>>|page5>>|page4>>
I am considering implementing a similar feature for navigating through the elements within my page. It would be a div with a sticky position on the left side, allowing users to easily jump to the last (or even previous) section with just one click, regardless of where they are currently on the page.
Is this achievable using JavaScript?
Thank you for your help!
After doing some research based on suggestions, I have come up with the following proposed solution. Please review and let me know if there are any missing points:
- Create an array of positions for all the anchors and another array to store trails
- Check the scroll point and take appropriate action: 1) If slot available, append to the trail 2) If the trail array is full, rotate 3) If the trail already exists, switch