RE: Javascript in CFC
Hrm... You're right. That doesn't make any sense though. -Original Message- From: Brad Wood [mailto:[EMAIL PROTECTED] Sent: Thursday, September 04, 2008 10:12 PM To: CF-Talk Subject: Re: Javascript in CFC - Original Message - From: "Andy Matthews" <[EMAIL PROTECTED]> > That's irrelevant. > > The ColdFusion code would completely process before ANY JavaScript code > would even make it to the browser. Andy, I don't think you understand how cflocation works. Even though it is a CF tag, the relocation does NOT happen on the server side. If you make a test file and place the following code in it: alert('test'); http://www.yahoo.com";> . and then hit that page, your browser will make two requests. The first request for your test page will come back looking much like this HTTP response: = HTTP/1.1 302 Moved Temporarily Date: Fri, 05 Sep 2008 03:04:33 GMT Server: Apache/2.2.4 (Win32) JRun/4.0 location: http://www.yahoo.com Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/html; charset=UTF-8 Content-Length: 6551 alert('test'); = Notice that the output of your page (the JavaScript) DOES get passed out to the browser. However, your browser (Internet Explorer at least) will ignore the body of the response and send out a second request for http://www.yahoo.com. So whether or not the code is in a CFC or not, the browser is who actually does the redirect. Of course, if one wants the JavaScript to execute BEFORE the redirect, you want to send back a 200 response like so: alert('test'); document.location.href = '<a rel="nofollow" href="http://www.yahoo.com">http://www.yahoo.com</a>'; ~Brad ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312062 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Javascript in CFC
- Original Message - From: "Andy Matthews" <[EMAIL PROTECTED]> > That's irrelevant. > > The ColdFusion code would completely process before ANY JavaScript code > would even make it to the browser. Andy, I don't think you understand how cflocation works. Even though it is a CF tag, the relocation does NOT happen on the server side. If you make a test file and place the following code in it: alert('test'); http://www.yahoo.com";> and then hit that page, your browser will make two requests. The first request for your test page will come back looking much like this HTTP response: = HTTP/1.1 302 Moved Temporarily Date: Fri, 05 Sep 2008 03:04:33 GMT Server: Apache/2.2.4 (Win32) JRun/4.0 location: http://www.yahoo.com Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/html; charset=UTF-8 Content-Length: 6551 alert('test'); = Notice that the output of your page (the JavaScript) DOES get passed out to the browser. However, your browser (Internet Explorer at least) will ignore the body of the response and send out a second request for http://www.yahoo.com. So whether or not the code is in a CFC or not, the browser is who actually does the redirect. Of course, if one wants the JavaScript to execute BEFORE the redirect, you want to send back a 200 response like so: alert('test'); document.location.href = 'http://www.yahoo.com'; ~Brad ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312059 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Javascript in CFC
I use document.location.href in javascript instead of cflocation. >Andy Matthews wrote: >> That's irrelevant. >> >> The ColdFusion code would completely process before ANY javascript code >> would even make it to the browser. > >Actually, you can have output go to the browser before the CF code >completes by using CFFLUSH. This would negate CFLOCATION though, so the >original poster probably removed that in favor of another method of >redirection (such as having it all in JavaScript with a CFABORT to stop >further processing after the error was detected). In any case, they >didn't say how it was solved, but what matters is that whatever they did >worked for them . > > >-- >Justin Scott, http://www.tlson.com/ ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312050 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Javascript in CFC
I have some CFCs I use to build needed javascript/html that is outputted onto pages at the time they are loaded. On Thu, Sep 4, 2008 at 1:29 PM, Andy Matthews <[EMAIL PROTECTED]>wrote: > That's irrelevant. > > The ColdFusion code would completely process before ANY javascript code > would even make it to the browser. > > -Original Message- > From: Justin Scott [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 04, 2008 1:24 PM > To: CF-Talk > Subject: Re: Javascript in CFC > > > This works? Am I missing something? How is the browser seeing > javascript > code in a cfc? > > The CFCOMPONENT and CFFUNCTION tags both support an "output" attribute that > can be set to yes to allow their output to be injected into the content > stream back to the user. > > > -- > -Justin Scott, http://www.tlson.com/ > > > > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312049 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Javascript in CFC
Andy Matthews wrote: > That's irrelevant. > > The ColdFusion code would completely process before ANY javascript code > would even make it to the browser. Actually, you can have output go to the browser before the CF code completes by using CFFLUSH. This would negate CFLOCATION though, so the original poster probably removed that in favor of another method of redirection (such as having it all in JavaScript with a CFABORT to stop further processing after the error was detected). In any case, they didn't say how it was solved, but what matters is that whatever they did worked for them . -- Justin Scott, http://www.tlson.com/ ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312048 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Javascript in CFC
That's irrelevant. The ColdFusion code would completely process before ANY javascript code would even make it to the browser. -Original Message- From: Justin Scott [mailto:[EMAIL PROTECTED] Sent: Thursday, September 04, 2008 1:24 PM To: CF-Talk Subject: Re: Javascript in CFC > This works? Am I missing something? How is the browser seeing javascript code in a cfc? The CFCOMPONENT and CFFUNCTION tags both support an "output" attribute that can be set to yes to allow their output to be injected into the content stream back to the user. -- -Justin Scott, http://www.tlson.com/ ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312047 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Javascript in CFC
> This works? Am I missing something? How is the browser seeing javascript > code in a cfc? The CFCOMPONENT and CFFUNCTION tags both support an "output" attribute that can be set to yes to allow their output to be injected into the content stream back to the user. -- -Justin Scott, http://www.tlson.com/ ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312046 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Javascript in CFC
This works? Am I missing something? How is the browser seeing javascript code in a cfc? From: chn g [EMAIL PROTECTED] Sent: Thursday, September 04, 2008 2:14 PM To: CF-Talk Subject: Re: Javascript in CFC Thank you, its working now. >alert() is lower case. If that doesn't work try this: > > > > >The cflocation is sending back a status code of 301 to your browser. In >fact, I don't even know if ColdFusion sends back any content created in >the reponse body or not. > >~Brad > >What's wrong with the following code? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312045 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Javascript in CFC
Thank you, its working now. >alert() is lower case. If that doesn't work try this: > > > > >The cflocation is sending back a status code of 301 to your browser. In >fact, I don't even know if ColdFusion sends back any content created in >the reponse body or not. > >~Brad > >What's wrong with the following code? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312044 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Javascript in CFC
> The cflocation is sending back a status code of 301 to your browser. You mean it sets 302 as a temporary redirect, not permanent as a 301 would be. > In fact, I don't even know if ColdFusion sends back any content > created in the reponse body or not. It doesn't when you use CFLOCATION. It's essentially the equivalent of setting a 302 status code, a Location header, then using CFCONTENT with the reset="yes" attribute. -- Justin Scott, http://www.tlson.com/ ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312043 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Javascript in CFC
CF runs on the server, before the Javascrtipt would even have a chance to hit the browser. -Original Message- From: chn g [mailto:[EMAIL PROTECTED] Sent: Thursday, September 04, 2008 1:05 PM To: CF-Talk Subject: Javascript in CFC What's wrong with the following code? ... Alert("Error"); http://#CGI.SERVER_NAME#/testfile.html";> It's not showing up alert box, directly displaying the html file. Thanks Chn ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312042 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: Javascript in CFC
alert() is lower case. If that doesn't work try this: The cflocation is sending back a status code of 301 to your browser. In fact, I don't even know if ColdFusion sends back any content created in the reponse body or not. ~Brad Original Message Subject: Javascript in CFC From: chn g <[EMAIL PROTECTED]> Date: Thu, September 04, 2008 1:04 pm To: CF-Talk What's wrong with the following code? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312041 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Javascript in CFC
> >Alert("Error"); > >http://#CGI.SERVER_NAME#/testfile.html";> First thing is that CFLOCATION sets a 302 header which tells the browser to redirect, and none of the "output" is sent to the browser. If you want to show an error and redirect, you'll need to do it all in JavaScript (also, alert should be all lower-case)... alert("Error"); document.location.href = '/testfile.html'; -- Justin Scott, http://www.tlson.com/ ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312040 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4