How to use HTML # anchor in a dynamic url
I want to link to a section of a dynamic page using the # anchor, something like this:
<a href=page.php?id=3#section-name>LINK</a>
It didn't work. What is the right way to do it?
你只提供了一半的代码,所以我只能给出一个正确的方法来做到这一点:
<body>
<a name="top"> </a>
<a href="#top">
Go To Top Of Page
</a>
</body>
When using anchor tags, you can target an element by its ID. Browsers will look for the ID before it looks for the name
attribute when the link refers to such.
<a href="#section-name>LINK</a>
will go directly to <div id="section-name">
if it exists.
Here's an example
Read: HTML Anchors with 'name' or 'id'?
A typical anchor tag works as follows:
a href link tag is written like so:
<a href="anchor_example2.html#a001">Jump to a001</a>
See the #a001 above? That is referencing an id in the html page, it will jump to it if you click this link.
To provide an example of how this id that we would jump to might look in a page look below.
<li id="a001">text here</li>
reference
链接地址: http://www.djcxy.com/p/88988.html上一篇: 锚点哈希到页面的底部
下一篇: 如何在动态网址中使用HTML#锚点