in HTML, url contains #, scroll page to header?

If my url is something like: http://www.thisisawebsite.com/page.php#about
How do i make it so when the link is clicked, it'll go to the header "about", or anywhere else i so desire?


You need to define the anchor in your markup (near your 'About' header):

<a name="about"></a>

EDIT :

Due to the discussion, the snarky downvotes (BTW - I upvoted Richard Jordan's answer) and my own edification; anyone else having a question about this should explore using an ID attribute on the actual element they want to link to:

<h1 id="about>About</h1>

Just markup the header on the target page with the id "about" ie

<h1 id="about>About</h1>

That way your link on the linking page http://www.thisisawebsite.com/page.php#about will go straight to the "about" header - a h1 in this example but it could be whatever you'd given the id of "about". Remember you should only use the id "about" once on the page though.

链接地址: http://www.djcxy.com/p/88992.html

上一篇: 在页面锚点不在Firefox中工作

下一篇: 在HTML中,url包含#,将页面滚动到标题?