|
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Javascript calling ColdFusion - will this work?
I'm trying to use this code to call a ColdFusion page:Thane Sherrington 08/21/02 09:40 A Yes that should work, I've used a similar technique for a bannerJon Hall 08/21/02 10:11 A At 10:07 AM 21/08/02 -0400, Jon Hall wrote:Thane Sherrington 08/21/02 10:18 A Thane,Dan G. Switzer, II 08/22/02 10:37 A > Thane,S. Isaac Dealey 08/22/02 11:55 A According to the different versions of O'Reilly's "JavaScript: TheDan G. Switzer, II 08/22/02 12:27 P
Author: Thane Sherrington
I'm trying to use this code to call a ColdFusion page: function Get_Referrer() { document.write("<script language='Javascript' src='http://www.stuffbythane.com/SiteTracker/test3.cfm?in=" + document.referrer + "&out=" + document.location + "'>"); document.write("</"); document.write("script>"); } Get_Referrer(); It doesn't appear to work. Is it possible to do this? I know I could change test3.cfm to test3.cgi and call a Perl page, but it was suggested that I could do it with CF as well. T
Author: Jon Hall
Yes that should work, I've used a similar technique for a banner program in the past. -- jon mailto:jonhall@ozline.net Wednesday, August 21, 2002, 9:37:13 AM, you wrote: TS> I'm trying to use this code to call a ColdFusion page: TS> function Get_Referrer() { TS> document.write("<script language='Javascript' TS> src='http://www.stuffbythane.com/SiteTracker/test3.cfm?in=" + TS> document.referrer + "&out=" + document.location + "'>"); TS> document.write("</"); TS> document.write("script>"); TS> } TS> Get_Referrer(); TS> It doesn't appear to work. Is it possible to do this? I know I could TS> change test3.cfm to test3.cgi and call a Perl page, but it was suggested TS> that I could do it with CF as well. TS> T
Author: Thane Sherrington
At 10:07 AM 21/08/02 -0400, Jon Hall wrote: >Yes that should work, I've used a similar technique for a banner >program in the past. That's what I thought, but it isn't working for me. This is the complete code I'm using - three files in total: Alright, I tried this, but I must be doing something wrong: Index.htm looks like this: <html> <body> Test page. <script language="Javascript" src="http://www.stuffbythane.com/SiteTracker/UpdatePageInfo.js"></script> </body> </html> UpdatePageInfo.js looks like this: function Get_Referrer() { document.write("<script language='Javascript' src='http://www.stuffbythane.com/SiteTracker/test2.cfm?in=" + document.referrer + "&out=" + document.location + " '>"); document.write("</"); document.write("script>"); } Get_Referrer(); Test2.cfm looks like this: <CFQUERY name="test" datasource="SiteTracker"> INSERT INTO Test (In, Out) VALUES "#URL.In#", "#URL.Out#" </CFQUERY> So far as I can tell, test2.cfm doesn't get called. Or if it does, it doesn't run. Nothing ever ends up in the database, and if I put popup Window code in test2.cfm, nothing happens. So I must be doing something wrong. T
Author: Dan G. Switzer, II
Thane, If all you care about is updating a hit counter and not displaying any code, use the following code: function Get_Referrer(){ var oCounter = new Image(); var sImg = "http://www.stuffbythane.com/SiteTracker/test2.cfm?in="; sImg += escape(document.referrer); sImg += "&out=" + escape(document.location); oCounter.src = sImg; } This will should work in any browser that supports JS v1.1. NOTE: You previous code may not have been working because of the lack of the escape() function. -Dan complete src="http://www.stuffbythane.com/SiteTracker/UpdatePageInfo.js"></script something > wrong. > > T > > > >
Author: S. Isaac Dealey
> Thane, iirc the JavaScript escape() function only works on one character at a time... so you'd actually have to cycle through the whole string and create a copy i.e. for ( x=0 ; x < document.referrer.length ; x++ ) { sImg += escape(document.referrer.charAt(x); } At least, this is what I've read in my javascript books... otoh unescape ( which decodes a urlencoded string ) works on the entire string at once... I think I actually made a urlencodedformat() function in my js libraries... function urlencodedformat(string) { var strNew = New String(""); for ( var x = 0 ; x < string.length ; x++ ) { strNew += escape(string.charAt(x); } return strNew; } hth Isaac Dealey Certified Advanced ColdFusion 5 Developer www.turnkey.to 954-776-0046
Author: Dan G. Switzer, II
According to the different versions of O'Reilly's "JavaScript: The Definitive Guide" I've got on my desk it says: (JavaScript 1.0; Jscript 1.0; ECMAScript v1; deprecated in ECMAScript v3) escape() encode a string Synopsis escape(s) Arguments s The string that is to be "escaped" or encoded Returns An encoded copy of s in which certain characters have been replaced by hexadecimal escape sequences. I know I've used it in the past to encode full strings without problem. I've also found that the JS: Definitive Guide is usually pretty good about document behavior if it varies between browsers or JS versioning. -Dan any "http://www.stuffbythane.com/SiteTracker/test2.cfm?in="; lack of unescape ( > which decodes a urlencoded string ) works on the entire string at once...
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||