Reveroom
asked on
Coldfusion, Javascript & Ampersands?
Hi Folks,
I've hit a bit of a stumbling block here and would appreciate your help.
I'm trying to pass a link between 3 sites, and the links include various parameters. I need to use a mix of cflocation and javascript window.location (the JS required because that page also has a cfflush).
Here's an example of the workflow;
// index.cfm \\
<cfset link1 = 'http://www.domain.cfm?param1=1¶m2=2'>
<cflocation url="http://otherdomain.com/track.cfm?link=#link1#">
// track.cfm \\
<cfset link2 = '#url.link#'>
<cfflush>
<script type="text/javascript">
window.location = "<cfoutput>#link2#</cfoutp ut>"
</script>
This works fine, except that anything after the '&' isn't being passed. So, the destination is only going as far as http://www.domain.cfm?param1=1
A bit of googling suggests this is a known issue, and I need to somehow escape it - but I'm not entirely sure how!
Any help would be much appreciated!
I've hit a bit of a stumbling block here and would appreciate your help.
I'm trying to pass a link between 3 sites, and the links include various parameters. I need to use a mix of cflocation and javascript window.location (the JS required because that page also has a cfflush).
Here's an example of the workflow;
// index.cfm \\
<cfset link1 = 'http://www.domain.cfm?param1=1¶m2=2'>
<cflocation url="http://otherdomain.com/track.cfm?link=#link1#">
// track.cfm \\
<cfset link2 = '#url.link#'>
<cfflush>
<script type="text/javascript">
window.location = "<cfoutput>#link2#</cfoutp
</script>
This works fine, except that anything after the '&' isn't being passed. So, the destination is only going as far as http://www.domain.cfm?param1=1
A bit of googling suggests this is a known issue, and I need to somehow escape it - but I'm not entirely sure how!
Any help would be much appreciated!
ASKER
Thanks for the swift reply, erik.
It's still not working for me however. If I do a straight cflocation to the destination url, it works fine. However, if I do it via the 'middle domain' (which uses the window.location), it's still stripping everything after (and including) the ampersand.
It's still not working for me however. If I do a straight cflocation to the destination url, it works fine. However, if I do it via the 'middle domain' (which uses the window.location), it's still stripping everything after (and including) the ampersand.
try to use
location.replace
or
href.location
location.replace
or
href.location
ASKER
Hi erik,
Still the same result - have tried both alternatives without success.
Still the same result - have tried both alternatives without success.
what browser are using .. try using different browser so we can see if this just a browser compatability issue
ASKER
Tried on both Firefox (Mac) and IE 7 (Win) - same result on both
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, SidFishes - that did indeed solve the problem! Much appreciated.
Thanks to erik once again too, your input is appreciated.
Thanks to erik once again too, your input is appreciated.
<cfset link2 = '#url.link#'>
<cfflush>
<script type="text/javascript">
window.location = "<cfoutput>#Evaluate(DE(Li
</script>