开发者

How to link to a specific part of a page

I have a rails app and one page is a 'command center' with links to a help center. Things like, signing up or new post, etc. How can i make it so that when you click on a link, not only does it redirect to the help center, but that specific section. I tried making my links, link_to('/help#sigingup', 'Sign Up Help') and then in the help i have <h1 name开发者_如何学Go='signingup'>Sign Up Help' Anyone know what i am doing wrong?


You want to use an anchor

for your link do something like;

link_to "Sign Up Help", help_path(:anchor => "signup")

this will give you a URL with #signup on the end.

and then in your help page where you want to be jumped to;

<a name="signup">Sign Up Help</a>


Partial links target IDs not Names

Make it id="signingup" instead of name=

that should work


You need to use the id attribute to create an anchor.

Have a read of the spec here: http://www.w3.org/TR/html4/struct/links.html#h-12.2.3

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜