散列在锚标记中 [英] hash in anchor tags

查看:90
本文介绍了散列在锚标记中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



例如,让我说我有 page1.html ,其中有3个链接

 < a href =page2.html# 1\" →1< / A> 
< a href =page2.html#2> 2< / a>
< a href =page2.html#3> 3< / a>

关于 page2.html ,我有那些也就是页面上的链接,即

 < a href =page3.html#1> 1< / a> 
< a href =page3.html#2> 2< / a>
< a href =page3.html#3> 3< / a>

但是当我点击#2 #3 链接从 page1.html ,它们总是在页面顶部打开,即使#2 #3 不在 page2.html 的屏幕上需要向下滚动才能看到。



不知道我在做什么错。

解决方案

您需要将 定位到 page2.html ,如下所示:

 < a name =1>< / a> 
...
< a name =2>< / a>
...
< a name =3>< / a>

- 这是HTML5之前的版本。现在,您使用 id 而不是 name


How do I load a page and get it to open at a certain location of the loaded page?

For example, lets say I have page1.html, which has 3 links

<a href="page2.html#1">1</a>
<a href="page2.html#2">2</a>
<a href="page2.html#3">3</a>

on page2.html, I have those links on the page also, i.e.

<a href="page3.html#1">1</a>
<a href="page3.html#2">2</a>
<a href="page3.html#3">3</a>

but when I click on the #2 or #3 link from page1.html, they always open at the top of the page, even though #2 and #3 are off the screen on page2.html which need to be scrolled down to to be seen.

Not sure what I am doing wrong.

解决方案

You need to put named anchors on page2.html, like so:

<a name="1"></a>
…
<a name="2"></a>
…
<a name="3"></a>

– This was before HTML5. Nowadays, you use id instead of name.

这篇关于散列在锚标记中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆