Is php footer included at the top of the link?

I have a footer section on my website where I want to include a back to top link. The problem is that he cannot determine which page of the site the user is, so he sends it to the html top index. Is there any way to achieve this?

I can’t use <a href="#">Back to top</a> since I have a basic href that links to the website’s index page.

This code worked well, cross browser too:

 <a href="javascript:void(0)" onclick="parent.window.scrollTo(0,0);">TOP</a> 
+4
source share
2 answers

You do not need php for this. Just add the link:

 <a href="#">Back to top</a> 
+5
source

Add a named anchor on your page immediately before the content to indicate the top of the current page. How:

 <a name="top"></a> <!-- Rest of your content here --> 

Then in the footer link to the anchor with:

 <a href="#top">Back to top</a> 
+7
source

Source: https://habr.com/ru/post/1441527/


All Articles