admin管理员组文章数量:1287514
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>
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>
Share
Improve this question
edited Jan 30, 2013 at 19:01
Tasos
asked Oct 23, 2012 at 10:55
TasosTasos
1,6424 gold badges29 silver badges47 bronze badges
2 Answers
Reset to default 7Add 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>
本文标签: javascriptBack to top link on php included footerStack Overflow
版权声明:本文标题:javascript - Back to top link on php included footer? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741240549a2363890.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论