开发者

Link to #comments on WordPress blog post do not go to the page, just sit there

When I click on the comments link on my blog the page is not redirecting to the link and rather stays in the same page.

When I start I'm at this URL: http://loc开发者_开发技巧alhost/wordpress

And the link I'm clicking on is addressed to here: http://localhost/wordpress/?p=3#comments

Why would the link not work?


The hash symbol (#) in a link tells the browser that it's an on page place anchor.

In this case, #comments is the place link and somewhere on the page is an anchor tag named comments.

If you look in the source code you should find a link in there like this:

<a name="comments"></a>

So when someone clicks on a link with #comments on the end, the browser knows to scroll down or up to that point on the page marked out by that anchor.

This isn't limited to just anchors and can be used to jump directly to a DIV or other sections on the page by a similar attribute markup.

Say on a long page you have many sections. If you want people to jump right to that section, you can add an ID to the element, DIV or heading like so:

<h3 id="privacy">Privacy</h3>

And to have them jump right there with a link, you can use this:

<a href="#privacy">Jump to privacy</a>

If you're clicking and nothing happens, no jump, no scroll, then it's most likely that the browser cannot find an element with a matching name or ID anchor point.

But, if you can see the named anchor in the source code, the page could also be too short to shift the document leaving you with nowhere to actually go.


Do you have a custom theme installed, or have you altered any of the theme's files? Could you provide a link to the page, so people can take a look at what might be wrong?

Edit: If the page is relatively short, which could mean that the comments section is already visible, it might be that the browser decides not to scroll to that section.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜