为什么命名锚在第一次引用时失败? [英] Why does named anchor fail on first reference?
问题描述
我有一个包含多个部分的长页面,想要链接到这些部分来自
另一个页面如下:
< a href =' 'http://www.mysite.com/content.html#section12''>Section 12< / a>
这里的内容是锚点的样子。 html:
< h2 id =" section12">< a href = http://www.mysite.com/index.html
target =" _self">返回目录< / a>< / h2>
如果我清除浏览器的缓存并点击第12部分index.html中的链接,我没有在content.html中找到正确的位置。但如果我回到
index.html并重试,该链接将(在随后的尝试中)将我带到
的正确位置。
这种行为在FF和IE中是一致的。
我也试过使用这样的独立锚:
< a name =" section12">
相同的结果。
我错过了什么吗?是否有一些技巧可以让命名锚点工作
第一次?
提前致谢。
I have a long page with several sections and want to link to these sections from
another page like this:
<a href=''http://www.mysite.com/content.html#section12''>Section 12</a>
Here''s what the anchor looks like in content.html:
<h2 id="section12"><a href=http://www.mysite.com/index.html
target="_self">Return to Table of Contents</a></h2>
If I clear my browser''s cache and click on the Section 12 link in index.html, I
do not go to the correct position in content.html. But If I go back to
index.html and try again, the link will (on subsequent attempts) take me to the
correct position.
This behavior is consistent in FF and IE.
I''ve also tried using a stand-alone anchor like this:
<a name="section12">
Same results.
Am I missing something? Is there some trick to getting a named anchor to work
the first time?
Thanks in advance.
推荐答案
deko写道:
deko wrote:
我有一个包含多个部分的长页面,并希望链接到这些部分来自
另一页如下:
< a href =''http://www.mysite.com/content.html#section12''>第12节< / a>
这里是锚点在content.html中的样子:
< h2 id =" section12"> ;< a href = http://www.mysite.com/index.html
target =" _self">返回目录< / a>< / h2>
如果我清除浏览器的缓存并点击index.html中的第12节链接,我就不会在内容中找到正确的位置html的。但如果我回到
index.html并重试,该链接将(在随后的尝试中)将我带到
的正确位置。
这种行为在FF和IE中是一致的。
我也试过使用这样的独立锚:
< a name =" section12">
相同的结果。
我错过了什么吗?是否有一些技巧可以让命名锚点工作
第一次?
I have a long page with several sections and want to link to these sections from
another page like this:
<a href=''http://www.mysite.com/content.html#section12''>Section 12</a>
Here''s what the anchor looks like in content.html:
<h2 id="section12"><a href=http://www.mysite.com/index.html
target="_self">Return to Table of Contents</a></h2>
If I clear my browser''s cache and click on the Section 12 link in index.html, I
do not go to the correct position in content.html. But If I go back to
index.html and try again, the link will (on subsequent attempts) take me to the
correct position.
This behavior is consistent in FF and IE.
I''ve also tried using a stand-alone anchor like this:
<a name="section12">
Same results.
Am I missing something? Is there some trick to getting a named anchor to work
the first time?
我认为页面太长,或者有太多的图片和东西需要加载?b $ b?我已经看到它也发生了,而我只是猜测
浏览器在它之前的所有内容被加载到浏览器之前找到了ID
。
-
Els http ://locusmeus.com/
无障碍网页设计: http: //locusoptimus.com/
" deko" < de ** @ nospam.comwrote:
"deko" <de**@nospam.comwrote:
>我错过了什么吗?
>Am I missing something?
我们是(一个URL)。
-
Spartanicus
We are (an URL).
--
Spartanicus
浏览器在将其前面的所有内容加载到浏览器中的
browser finds the ID before all the content that preceeds it is loaded
之前找到该ID。
into the browser.
这是我考虑的事情 - 页面是用php动态生成的,
确实有一些更大的图像。
在进行故障排除时,我从页面源获取了一个静态页面 -
仍有同样的问题。然而,这是唯一有意义的,
,因为在那一点上,一切都是通用的HTML,带有简单的锚点。
我想你可能是正确。如果是这样,这是浏览器错误。 IE和FF
都有它。浏览器应该能够识别URL中的锚点,呈现
页面,然后相应地定位自己。
That''s something I considered - the page is dynamically generated with php and
does have some larger images.
While troubleshooting, I took the page source and made a static page out of it -
still had the same problem. Yet this is the only thing that makes any sense,
since, at that point, everything was generic HTML with simple anchors.
I think you may be correct. If so, this is browser bug. And both IE and FF
have it. A browser should be able to recognize an anchor in a URL, render the
page, then position itself accordingly.
这篇关于为什么命名锚在第一次引用时失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!