Posted in Development | Posted on 10-08-2005 | 7,691 views
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?


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.
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 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.
Oguz: I'd blame CF, but the one google hit I got mentioned .Net. Anyone care to try this same experiment in .net?
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/demos/test2.cfm?x=1#to... instead).
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.)
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.
<a href="http://www.macromedia.com/cfusion/knowledgebase/in...; target="_blank">http://www.macromedia.com/cfusion/knowledgebase/in...;
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....
#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.
[Add Comment] [Subscribe to Comments]