Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the full url?

Status
Not open for further replies.

minli98

IS-IT--Management
Aug 30, 2005
178
US
Hi all,

How can I get in Coldfusion, the equivalent of document.URL property in Javascript -- the full url including all the url parameters?

Regards,
Min
 
Try this:
Code:
<cfoutput>#cgi.script_name#?#cgi.query_string#</cfoutput>


Hope This Helps!

ECAR
ECAR Technologies, LLC

"My work is a game, a very serious game." - M.C. Escher
 

To include the http: and the domain name:

Code:
<cfoutput>#cgi.server_name##cgi.script_name#?#cgi.query_string#</cfoutput>

Note that this mirrors how the page is called so if the page is called without the subdomain then it will not include the subdomain in cgi.server_name
 
Depending on how acurate you need it and also depending on the format of URL you use, you might need a different variation:

Code:
<cfoutput>http<cfif cgi.HTTPS EQ 'Yes'>s</cfif>://#cgi.server_name##cgi.path_info#<cfif cgi.query_string NEQ ''>?#cgi.query_string#</cfif></cfoutput>

This will give you any params passed in a URL friendly format, will check for SSL and also will hide the ? if there is no query string.

Hope this helps

Wullie

Fresh Look - Quality Coldfusion/Windows Hosting

The pessimist complains about the wind. The optimist expects it to change. The leader adjusts the sails. - John Maxwell
 
Wullie,
Good answer, however, cgi.HTTPS will = 'on' or 'off' not 'Yes' or 'No'

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
minli98,

Those type of links are called Anchors and I really don't think you will be able to catch those in CF. The reason I say that is that the browser handles those links, not the server.

It basically works as follows:

[ignore]1) User calls 2) Server returns output for 3) Browser reads anchor link and directs user to section_1.
[/ignore]
The server doesn't need to know about those links and once you are on the page, there is no further call to the server if you click an anchor so the server never knows about it.

Hope this helps


Wullie

Fresh Look - Quality Coldfusion/Windows Hosting

The pessimist complains about the wind. The optimist expects it to change. The leader adjusts the sails. - John Maxwell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top