Skip to main content
BreakawayPaul
Inspiring
May 19, 2009
Question

Need help with an "exit door" page

  • May 19, 2009
  • 2 replies
  • 924 views

My office has a page on our webserver that serves as an "exit door". It basically tells you when you're leaving our site (they do this because it's a gov't site, and thus rquired) and you have to click on a link to confirm that you want to leave.

The way it works is that when you code a page with a link that needs an exit door, you prepend the url with "exit.cfm?link=" and then the URL. It works adequately on simple URLS that pass no parameters. Where it has a problem is when a URL has GET arguments like ?page=23&item=43.

The original coder used URL.link, which of course only captures the first GET argument. As a work-around, we're required to edit the target URLS being passed to the exit door and replace things like & and # with [amp], [pound], etc. Needless to say, this gets rather tedious, so I decided to have a look at that old exit door page to see what I could do with it.

After playing around a bit, I achieved  a reasonable level of success by using the following:

#xmlformat(ListDeleteAt(CGI.QUERY_STRING,1,"="))#

This gives me a properly encoded full URL to use as a link on the exit door page. But there's one problem. If there's a link that contains an anchor (like foo.com#section1) it doesn't capture the anchor. The # and what's after it isn't being passed.

I'm trying to figure out how to make this work.  Has anyone else here had to make an exit door, and if so, how did you do yours?

    This topic has been closed for replies.

    2 replies

    Participating Frequently
    May 20, 2009

    The anchors are not sent to the server at all, they're processed

    exclusively on the client side:

    http://en.wikipedia.org/wiki/Fragment_identifier[/url]

    Mack

    BreakawayPaul
    Inspiring
    May 20, 2009

    Thanks mack.  I'm starting to think the answer to this is "it can't be done".  Which is probably why my predecessor was replacing &s with [amp]s.

    What led me to try to change this was that I was trying to build a regex for Dreamweaver that changed things like & and # to [amp] and [pound], but only when the URL began with the exit door page URL.  I was only able to get my regex to replace one occurance of an item per pass, which sort of defeated its purpose.  So I decided to change the exit door page instead.

    Maybe I'll go back to trying to get the regex to work.

    Ian, thanks for your help as well.

    ilssac
    Inspiring
    May 19, 2009

    Have you not tried the urlEncodedFormat() and urlDecode() functions designed just for this purpose?

    BreakawayPaul
    Inspiring
    May 19, 2009

    Yes, but this still doesn't capture anchors at the end of the URL.

    domain.com#chapter1 still shows up as domain.com

    ilssac
    Inspiring
    May 19, 2009

    It works for me.

    urlTest.cfm

    <cfset urlString = "www.test.org?a=1&b=ABC&c=1x3##foobar">
    <cfdump var="#URL#">
    <cfoutput><a href="urlTest.cfm?url=#urlEncodedFormat(urlString)#">Link</a></cfoutput>