So, I've been trying to debug an issue with Galleon that I only saw on this server, not my local box. For some reason, whenever an IE browser posts a new message, instead of the current thread reloading, the user was pushed to the home page. (You won't see this now as I've disabled the cflocation.) I couldn't understand why, so I added some debugging.
When a new message is created, I use cflocation to reload the page so that a refresh of the browser won't repost the message. The message was being created, and the cflocation was running, but when the page reloaded, the value of the Thread ID wasn't valid anymore. Why? Because the anchor in my cflocation URL, #top, was being appended to the url value.
In other words, in Firefox, when the cflocation ran and the page loaded, url.threadid was the right string. In IE, doing the exact same operation, the value of url.threadid was theid#top.
I tried like heck to replicate this locally, but couldn't do so. Finally I created a simple test. Go to http://ray.camdenfamily.com/demos/test.cfm in Firefox and you will be pushed to test2.cfm?x=1#top. The dump you see is the URL scope. Notice that all you see is X and 1. Hit the exact same URL with IE and the value of x is not 1#top.
I did some Googling, and I did find one other user who saw the exact same thing in a .Net application under IIS6. Is anyone else seeing it?
Archived Comments
Not quite sure what you mean about the URL scope dump?
With that URL the value of X should be 1 and after the page has loaded the browser should try to position the page to the anchor named top.
Every browser I tried correctly shows X = 1 and tries to jump to the anchor top.
Ray, I see the behavior you described (x = 1#top instead of x = 1) using IE6 on Windows XP (all the latest updates). Opera and Firefox pass the correct value and anchor. I wonder how the submission of the HTTP request differs between IE and the other browsers...
Ray,
I got the same results as you (using WinXP). With Firefox (v1.07) I received "x=1" and with IE6 I received "x=1#top".
I just did a quick test on my local IIS6 test server and I get the same results using a test page similar to the one you have on your site.
Another quick update. This does seem to be caused by <cflocation>. If you hit the page directly with IE6 using the URL: http://ray.camdenfamily.com... then everything works as expected.
Hi Ray,
I would also suggest to check CF version.
Base CF 7.0 (the first version of 7) has also some problems with CFLOCATION. I had same problem on my server but after upcoming updates problem has gone.
Just an idea.
Sean, I just meant: cfdump var="#url#". So, odd that it didn't bug for you, and it did for everyone else.
Oguz: I'd blame CF, but the one google hit I got mentioned .Net. Anyone care to try this same experiment in .net?
Also - anyone want to try this w/ PHP? My only IIS6 box is this one, so I don't want to put PHP on it just for a test.
Have you tried disabling HTTP keep-alive in IIS? I experienced something somewhat similar in IIS5 a while back and that was the most effective workaround I found.
This sounds alot more like a browser issue than an IIS issue. The web server should be doing the same thing regardless of browser.
Ray, I meant it was unlikely to be IIS since then you'd see it with more browsers. Since you're only seeing it for Win/IE6 (and not Mac/IE), then it looks like a *browser* issue - mishandling a 302 location header - not a server error.
I notice that the actual response is: location: test2.cfm?x=1#top
You might try using a full URL (with http://ray.camdenfamily.com... instead).
Sorry for misreading you. I think what I may do is a hack, simply add a dummy url var before the anchor.
Did you try using the full URL instead of just the filename? I'm curious to know whether that makes a difference to IE6.
As Sean says IE must be the culprit, not cflocation. We've seen the same thing with ISAPI_rewrite redirections. The simplest solution is to add an ampersand before the anchor pound sign in the url.
Sean, the full URL didn't help.
Julian: I'm not so sure it is just IE as since tests locally w/ Apache don't show the same result. I'm going to try a &, and if it doesn't help, I'm going to add &dummy=1. (Not on the test, but in Galleon where I first found this bug.)
Sorry Ray, I should have been more precise: it's the IIS/IE combination that seems to be at fault, rather than IIS/CFLOCATION.
Just an FYI, but &#anchor seemed to work ok. I'll be releasing an updated Galleon sometime today.
Ray,
I've notice this same thing happening every now and again on my dev box. It started after I installed the JRun4 Updater 6. I'm running CFMX 6.1 via JRun4 with IIS6 on Windows 2003.
FYI -
<a href="http://www.macromedia.com/c..." target="_blank">http://www.macromedia.com/c...
I found this thread this morning. Your &#anchorName hack worked just fine. Thank you very much.
Thanks very much for the tip. Worked with &##anchorName
I have encountered this problem. Here are my solutions:
Linking to Named Anchors in CF to ANOTHER page
Coldfusion will throw an error if you link to a named anchor on another page using #, unless you use the following code:
<cflocation url = "index.cfm?ID=7j&##6" addToken = "No">
The critical part is &##6 at the end of this example URL. This needs to be added to the END of the string, otherwise it is ignored.
Linking to Named Anchors in CF to the SAME page
If you link to a named anchor on the SAME page using #, Coldfusion will NOT pass the named anchor on the URL. See below:
<cflocation url = "index.cfm?ID=7j&##6" addToken = "No">
</cfif>
THIS WILL NOT WORK....
You MUST insert the named anchor in the form action path. E.g.
<form action="index.cfm?id=3c&#A" method="post" name="form" id="form" enctype="multipart/form-data">
Of interest, the original method WILL work in Firefox. I hova found it is only IE, that does not like posting back to the same page.
Hope this helps....
I am trying to link from one cfm (CheckIn_Update.cfm) back to a specific named anchor in another cfm (CheckIn.cfm - anchor name 'Test') as you discussed in this post. In a cfm (CheckIn.cfm), I send information to a 2nd cfm using <a href="CheckIn_Update.cfm?RecordID=#OCT251700.RecordID#&Target=Test"> Where 'Test' is the name of an anchor. In the 2nd cfm (CheckIn_Update.cfm), I allow the user to update a form & then return to the original cfm to a specific anchor named 'Test" using <cflocation url="...../CheckIn.cfm##Test"> which works corrently. What I now need to do is to make the anchor name (Test) in the 2nd cfm a variable once it reaches the CheckIn_Update.cfm since the anchor name will change with each use depending on the choice selected on the 1st cfm (CheckIn.cfm). I am sending the anchor name through the variable 'Target' to the 2nd cfm and I have declared the anchor <cfparam name="URL.Target" default=""> in the 2nd cfm and created a variable for the changing anchor called 'Target2' <cfset Target2 = #URL.Target#>. How do I put the variable name in the cflocation statement where I call the anchor - <cflocation url="...../CheckIn.cfm##Test">?
Are you asking how to replace
#test
with some dynamic value?
If so, and if your value was in the variable 'mark', then you could do this
<cflocation url="foo.cfm###mark#">
The # hashmark is doubled to escape it and then #mark# is used since it is the variable.