0

我在“http://test.com/mypage”页面上有一个带有“#myanchor”的链接。它会让我转到“http://test.com/mypage#myanchor”,对吗?但我对这个锚点有疑问,将我移至索引页面“http://test.com#myanchor”。

你能解释一下为什么吗?

谢谢。

编辑

哈,我在页面上发现了一些奇怪的代码:

var base = document.domain;
var port = window.location.port
document.write('<base href="http://' + base + (port?':':'') + port + '" />');

问题已解决。

@Surreal Dreams,如果你愿意,你可以解释它是什么,我会选择你的答案:)

4

2 回答 2

0

原因,test.com 默认加载 index.html。所以 test.com/#myanchor 和 test.com/index.html#myanchor 是一样的

于 2012-05-30T14:26:31.900 回答
0

你确定你的链接没有设置为href="/#myanchor"?这将导致您定位到http://test.com#myanchor.

如果您可以显示实际的 HTML,我可以给您一个更明确的答案,但这是可能的原因。

于 2012-05-30T14:25:10.513 回答