If I do a link_to 'XYZ', '/usage/Faq.html#GB_limit' in my view ...
can I detect "GB_Limit" in my controller? Where?
I know I can do link_to 'XYZ', '/usage/Faq.html?bookmark=GB_limit' and I can find GB_limit in params[:bookmark].
If I do a link_to 'XYZ', '/usage/Faq.html#GB_limit' in my view ...
can I detect "GB_Limit" in my controller? Where?
I know I can do link_to 'XYZ', '/usage/Faq.html?bookmark=GB_limit' and I can find GB_limit in params[:bookmark].
Ralph Shnelvar wrote in post #969900:
If I do a link_to 'XYZ', '/usage/Faq.html#GB_limit' in my view ...
can I detect "GB_Limit" in my controller?
Not to my knowledge. I believe -- and I hope someone will correct me if I'm wrong -- that the browser removes the #fragment section of the URL, and merely does a HTTP GET '/usage/Faq.html', so that the server never even sees the #fragment. Therefore, the only way I'm aware of to process the #fragment is to use client-side JavaScript.
(BTW, you should really be using lowercase for your HTML filenames, or else you're likely to run into case sensitivity issues.)
Where?
I know I can do link_to 'XYZ', '/usage/Faq.html?bookmark=GB_limit' and I can find GB_limit in params[:bookmark].
Right. The ?query=string is meant for the server. The #fragment is meant for the client. That's just how HTTP URLs work.
Best,
Greg Donald wrote in post #969911:
(BTW, you should really be using lowercase for your HTML filenames, or else you're likely to run into case sensitivity issues.)
I used to think that too, but then I tested it a few months back and found every browser I tried worked fine with incorrect case in a URL.
http://example.com/Home.html worked when the actual URL was http://example.com/home.html
I still go all lowercase just out of habit.. looks cleaner too.
AFAIK this is server-dependent, not browser-dependent -- that is, some servers are case-sensitive and some are not.
For example, my website is hosted on a case-sensitive server (Apache on some sort of *nix). I just tried typing in http://www.marnen.org/Music.html and got an error (Firefox 3.6, Mac OS X 10.6). marnen.org: Homepage of Marnen Laibow-Koser , however, gives the expected page. Do you get different results? If so, in what browser?
It's best to always treat your server (and browser) as if they're case-sensitive.
-- Greg Donald destiney.com | gregdonald.com
Best,
I think if you really need to pass the (window.location.hash) to the server when you have to go with JavaScript. In your case since you have a bookmark inside the link href, I would create a custom XHR request with passing a bookmark as a GET parameter. I hope that something like this can be helpful to you: jQuery(function($) { $('#your_special_link_with_bookmark').click(function() { var href = this.href; $.get(href, {'bookmark' : href.substr(href.indexOf('#') + 1)}) }) }) I didn't test the example, but something like this is a very small hack and you can adjust it to your needs.