I have a footer section on my website where I want to include a back to Top link. Problem is that it can't detect on which page of the site the user is so it sends it in the index html top. Is there any way to achieve this?
I can't use <a href="#">Back to top</a>
since I have a base href that links to the index page of the website.
This code worked well, cross browser too:
<a href="javascript:void(0)" onclick="parent.window.scrollTo(0,0);">TOP</a>
Add a named anchor in your page just before the content, to specify the top of your current page. Like:
<a name="top"></a>
<!-- Rest of your content here -->
Then in your footer, link to the anchor with:
<a href="#top">Back to top</a>
You don't need php for this. Just add a link like this:
<a href="#">Back to top</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With