开发者

Rails3 -- Is there a way to tell if a hash link (internal link) has been used?

I have a client who wants a page to have their terms of service hidden at the bottom of a page with the following criteria:

1) on normal page load, the tos should be hidden with a js trigger next to the title to toggle the display 2) if an internal link was clicke开发者_开发百科d, either a)from the current page or b)from an external page, the tos should show

For #1 and #2a (clicking on internal link from said page), no problem. It is for #2b, when a user is coming from another page with #tos in the url, that I don't know how to detect the presence of #tos.

So, if UserA is on page /foo and clicks on a link to /bar#tos, how can I tell when processing the request for page /bar that the anchor #tos exists so that I can show the terms of service

The only thing I could think of is to dump the request object and look in there hoping it was in path_in, query_string or something else, but it wasn't. Otherwise, I really don't know where to look.

I know, internal links are for linking inside of a page and if I need page /foo to tell page /bar to do something, I should use parameters and not internal link. However, my client wants the hash link, #tos, for seo reasons so I am trying to find a solution for them. Any help?


You need to address this with JavaScript most likely. You should be able to do something like:

if(window.location.hash == '#tos'){
    showTos();
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜