链接到页面的特定部分

时间:2013-01-20 10:56:21

标签: html ios wordpress safari

我尝试了以下所有方法:

<a name="test"></a>
<a id="test"></a>
<h4 id="test">SOME TEXT</h4>

然后像这样链接到他们:

<a href="pagename#test">

所有上述工作都适用于Firefox,IE和Chrome,但它们都不适用于Mac上的Safari 5.xx。非常感谢任何帮助。

2 个答案:

答案 0 :(得分:7)

<a href="#test">Go to Test</a>

。 。

<div id="test">This is Test.</div>

这应该有用。

EDITED: 此外,如果您想链接到不同页面中的特定ID,我认为您可以使用:

<a href="somepage.html#test">Go to Test on some different page.</a>

答案 1 :(得分:1)

看起来您对锚点的工作方式存在误解,您需要使用href属性。

<a name="test"></a>          <!-- not required -->
<a id="test"></a>            <!-- not required -->
<h4 id="test">SOME TEXT</h4> <!-- this is correct -->

要链接到<h4 id="test">元素,请执行此操作(如果目标位于同一页面上):

<a href="#test">Go to Test</a>

如果定位于其他页面:

<a href="other_page.html#test">
相关问题