Html 子页面上的锚点 #top 发送到索引页面
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11994834/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The anchor #top on subpages send to index page
提问by Nick
I have anchor on subpages:
我在子页面上有锚点:
<a name="#top"> </a>
<a href="#top">Back to top</a>
It works on the index page but it doesn't work on the subpages.
它适用于索引页面,但不适用于子页面。
Link always - site.com/#top
始终链接 - site.com/#top
Maybe it's problem with JavaScript (for example, Fancybox,etc)
可能是 JavaScript 的问题(例如 Fancybox 等)
Update:Fixed - <base href="site.com/" />
in <head>
更新:固定 -<base href="site.com/" />
在<head>
回答by Steve
Shouldn't it be like this? (without the # on the name)
不应该是这样吗?(没有名字上的#)
<a name="top"> </a>
<a href="#top">Back to top</a>
Alternatively, you could do this:
或者,您可以这样做:
<div id="top">Some content</div>
<a href="#top">Back to top</a>