Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Anchored Links / CF URL params

New Here ,
May 18, 2006 May 18, 2006
I use CF6. I have a redirect page that uses URL parameters and CFlocation to redirect the browser. I have noticed that, given the following link:

mypage.cfm?x=123&y=321&s=http://mysite.com/page.pdf#Anchor5

. . .before I attempt any redirect, if I start to output some variables like #url.s#, #cgi.query_string#, and even dumping the URL structure, none of these shows "#Anchor5", which is clearly a part of the request URL. Now, I know that most servers don't care about the #Anchor5 because this "anchoring" is interpreted by the browser, but I need to know that that value is present for my tracking and CF won't show it to me.

Does anyone know if there is a way to expose this value in CF?

Thanks,

Droddy
1.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 18, 2006 May 18, 2006
Not quite sure what you are attempting here, but if I understand you correctly, you are wanting to pass the literal text value of "#Anchor5", right?

Have you turned on debugging? I suspect that if you do, you'll see an error because CF will see the "#" and think it's the start of a variable value to output, but since there isn't a closing "#", you'll get an error.

You'll want to enclose the whole thing in single quotes, i.e. mypage.cfm?x=123&y=321&s=' http://mysite.com/page.pdf#Anchor5'
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 18, 2006 May 18, 2006
-----
You'll want to enclose the whole thing in single quotes, i.e. mypage.cfm?x=123&y=321&s=' http://mysite.com/page.pdf#Anchor5'
-----

I'm not creating that string in my CF. It's coming in in the URL of the request. To rephrase it, here's what is in the link someone clicks to get to my CF page:
http://mydomain.com/mypage.cfm?x=123&y=321&s=http://mysite.com/page.pdf#Anchor5

I'm trying to extract "URL.S" or use the URL structure or cgi.query_string and I find that the part of the request URL I'm looking for, "#Anchor5," is not being found--even though I can see it right there in my browser. Try this:

Create the following CF page and go to it with "#Anchor5" at the end of the URL:

mypage.cfm:
( http://mydomain.com/mypage.cfm?x=123&y=321&s=http://mysite.com/page.pdf#Anchor5)
----------------------------------------------------
<cfdump var="#URL#">
<cfdump var="#cgi.query_string#">
<cfdump var="#URL.s#">
----------------------------------------------------

See how CF ignores the fact that the request URL has "#Anchor5?"

Thanks,

David Droddy
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 18, 2006 May 18, 2006
Try two octothorps instead of one. It's worth a shot.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 19, 2006 May 19, 2006
quote:

Originally posted by: Dan Bracuk
Try two octothorps instead of one. It's worth a shot.


octothorp? what's that?
If you mean the pound (#) sign? I've tried doubling that too--with no better results

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 19, 2006 May 19, 2006
This is not a Coldfusion issue.

Per W3C URI spec, the anchor text is not part of the query string.

Since no programmer in his right mind would try and switch off the anchor string, most (all?) web servers (IIS, Apache, etc.) do not bother to strip it off into a CGI variable.
Use a normal URL variable or rethink your approach.

If you really must get this information then its not too hard to add the anchor text to the CGI array if you compile your own Apache server executable.


Also, "Octothorpe" is the correct name for #.
£ is the "pound sign".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 19, 2006 May 19, 2006
Actually, you could use Apache's mod_rewrite to automatically generate a URL var from the anchor text.
Not that I recommend doing this as other than as an academic exercise.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 19, 2006 May 19, 2006
quote:

Originally posted by: MikerRoo

Since no programmer in his right mind would try and switch off the anchor string, most (all?) web servers (IIS, Apache, etc.) do not bother to strip it off into a CGI variable.
Use a normal URL variable or rethink your approach.

If you really must get this information then its not too hard to add the anchor text to the CGI array if you compile your own Apache server executable.


Also, "Octothorpe" is the correct name for #.
£ is the "pound sign".




I am not trying to strip anything--rather, I need to detect what the Anchor string is and log that in my DB. Unfortunately, I'm using IIS, not Apache.

Octothorpe. . .seems a bit archaic and hard to find. How about "number sign?" I appreciate the specificity of your word of choice, but if noone knows what you mean by the term, is it really effective usage?

Cheerio!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 19, 2006 May 19, 2006
Here's a better example of what I'm trying to do again:

Create the following CF page and go to it with "#Anchor5" at the end of the URL:

mypage.cfm:
( http://mydomain.com/mypage.cfm?x=123&y=321&s=http://mysite.com/page.pdf#Anchor5)
----------------------------------------------------
<cflocation url=url.s>
----------------------------------------------------

Notice that, on the cflocation, #Anchor5 is lost. Hence, I can't redirect my user to the proper position in the page when I redirect him. I find that if URL.S is pointing to a PDF, this does not work. If it is pointing to an HTML file, the redirect works properly--even though the browser does not show the Anchor string in the address bar after the redirect.

BTW, All of these examples to the PDF are a problem in IE, but not in FireFox--neither browser has the Anchor string in the address bar after the redirect, but FireFox does hop down to the correct anchor point.

Someone really should try this to see what I'm getting at.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 19, 2006 May 19, 2006
Anchors are simply never returned to the Server through URL's or any other CGI variable. What's the point, server could care less, it's a browser only function. If you truly want it to come back to you substitute something like a ~ for the #. Then change the ~ back to a # in the cflocate.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 19, 2006 May 19, 2006
We know what you are trying to do.

We are telling you that there is a reason IIS does not support it. Rethink your approach or use a proper web server like Apache.

In IIS you have some choices:
1) Make the anchor on the fly from a URL parameter.

2) Use javascript to do the redirect, on the client side) with the anchor. JS can see the anchor text.

3) DON'T USE THIS KIND OF REDIRECT APPROACH! Be a polite web site that follows usability guidlines and point your links to the indicated location without any trickery.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
May 19, 2006 May 19, 2006
LATEST
quote:

Octothorpe. . .seems a bit archaic and hard to find. How about "number sign?" I appreciate the specificity of your word of choice, but if noone knows what you mean by the term, is it really effective usage?

Just in case anybody was interested..... OCTOTHORPE

Phil
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources