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

function for getting full current page url

Guest
Jan 18, 2007 Jan 18, 2007
Hello Everyone!
Is there a funtion to get your full current page url? With the http:// and possible url variables?
Thank you!
TOPICS
Getting started
2.7K
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

correct answers 1 Correct answer

Community Expert , Jan 18, 2007 Jan 18, 2007
<cfoutput>#" http://" & CGI.HTTP_HOST & CGI.SCRIPT_NAME & IIf(len(trim(CGI.QUERY_STRING)),DE('?'),DE('')) & CGI.QUERY_STRING#</cfoutput>

Translate
Community Expert ,
Jan 18, 2007 Jan 18, 2007
<cfoutput>#" http://" & CGI.HTTP_HOST & CGI.SCRIPT_NAME & IIf(len(trim(CGI.QUERY_STRING)),DE('?'),DE('')) & CGI.QUERY_STRING#</cfoutput>

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 ,
Jan 18, 2007 Jan 18, 2007
> <cfoutput>#" http://" & CGI.HTTP_HOST & CGI.SCRIPT_NAME & IIf(len(trim(CGI.QUERY_STRING)),DE('?'),DE('')) & CGI.QUERY_STRING#</cfoutput>

Unless it's HTTPS, or running on a port other than 80... ;-)

I don't have access to an HTTPS-running server @ present, otherwise I'd
provide a more helpful answer. However there are two additional CGI
variables which get set to (something) if the request was made via HTTPS.

To deal with the port, there is CGI.SERVER_PORT. If it's other than 80 (or
443 if HTTPS), the one should include a colon and the port number after the
HTTP_HOST value.

--
Adam
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
Jan 18, 2007 Jan 18, 2007
Thank you bkbk and Adam. In this case it's http, and the above script works perfectly well! You're remaks are taken under consideration Adam. Thanks!
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 ,
Jan 25, 2007 Jan 25, 2007
I wanted to piggyback on this question, because I have a similar problem.

I have used the CGI variables to get the info you mentioned. However, it does not seem to capture anchor tag info.

Consider the following:

http://mydomain.com/foo/bar/page.cfm?var=blah#thisPageSection

The last part is not captured by the cgi.query_string, nor anywhere else, that I can figure out.

Does anyone have any advice on how to get the full url, for redirect purposes? I know I can do it via Javascript, but was trying to keep it all within CF logic, if possible.

Tx,

Kendra
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
Community Expert ,
Jan 26, 2007 Jan 26, 2007
LATEST
> I have used the CGI variables to get the info you mentioned.
> However, it does not seem to capture anchor tag info.

No surprise. In the HTTP protocol, the character # is a URL delimiter. The part #thisPageSection, so-called fragment identifier in HTTP terms, is just for the scrolling convenience of the browser. The browser does not send it to the web server. That is why you cannot access it via CGI. As you have already discovered, the answer is to use Javascript.




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