Copy link to clipboard
Copied
Is there a way to use coldfusion code to detect the URL string of a remote server/site if that server/site calls the .cfm page from my server using an iframe.
Sounds confusing.... I have a page on my site called test.cfm placed at the root. I want to call that test.cfm page with an iframe from my blog... and on that test.cfm page the code (that I don't know how to write) will output the blog's URL string to the screen.
Put a dump of the CGI scope in the page to be displayed, you might have it in CGI.referrer. Bear in mind though as with anything referrer, it relies on the user's browser sending you that data. Different browsers may do it differently, and you can't guarantee it'll do it at all.
Copy link to clipboard
Copied
Put a dump of the CGI scope in the page to be displayed, you might have it in CGI.referrer. Bear in mind though as with anything referrer, it relies on the user's browser sending you that data. Different browsers may do it differently, and you can't guarantee it'll do it at all.
Copy link to clipboard
Copied
The dump did produce a couple data points I was looking for.
I did not know that about some browsers not returning CGI variables.... Is it only the http_referer variable?
Copy link to clipboard
Copied
A server cannot decide what it is sent by a browser, it's up to the browser to send what it likes. Often it's in their best interests, and it generally improves people's browsing experience as sites can do things exactly like what you're attempting here. However the fact remains that they don't *have* to send this information, and it doesn't *have* to be accurate.
I suspect the majority of browsers (certainly the popular ones) will send it by default; however things like robots and spiders might not. You need to make sure your site will still work without it, you don't want the site to break when something like Google spiders your site - firstly because you'll get spammed by all your error reports, but secondly because Google will downrank you if every page they hit returns an error 500.
Copy link to clipboard
Copied
I did not know that about some browsers not returning CGI variables.... Is it only the http_referer variable?
All the CGI variables that are prefixed with "http_" come from the user agent (eg: a web browser). So they're set by the user agent, meaning the values cannot be relied upon to be "true". The agent can send whatever they like in those values.
The CGI variables that are not prefixed by "http_" are set by the web server or the CF server, and those can be relied upon.
--
Adam
Copy link to clipboard
Copied
Thanks for the info.
My end goal was to replicate something like the quantcast analysis script but with iframe and cf instead of javascript.
I was also going to include a form that let's the person who knowingly puts my iframe on their page add additional data about their page.
I suppose there is a better way...
Copy link to clipboard
Copied
Regarding, "I was also going to include a form that let's the person who knowingly puts my iframe on their page add additional data about their page."
I suggest an experiment. Knowingly put that iframe into a new page and have it do whatever it does. Then look at the cgi variables on the receiving page. Was the http referrer the parent page or the iframe? Is that information relevent to what you were considering?
Copy link to clipboard
Copied
Absolutely. The experiment was a success... I was just a little concerned about the news that not all browsers share certain data.
I tested the iframe on a blogger page and the http_referer and remote_host gave me the info I needed.
For now I'm happy and I suppose I'll just figure out what to do in those cases where the cgi's mentioned above do not return the data I need.
Copy link to clipboard
Copied
Personally for now, I'd just put in something to the tune of this:
<cfif len(cgi.http_referrer) >
<!--- process code here --->
<cfelse>
<cfmail to="me" subject="Weird request" type="html">
<cfdump var="#cgi#" />
</cfmail>
</cfif>
That way you'll get an idea what kind of requests don't have the data, and you'll process it whenever possible.