No, more like this <cfset jsVar = "myCFVar" />
<cfoutput> <script> var jsVar = '#jsVar#'; </script> </cfoutput> <script src="srcJS.js"></script> On Thu, Oct 28, 2010 at 2:19 PM, Rick Faircloth <ric...@whitestonemedia.com>wrote: > > Yes, I definitely like the idea. > I didn't like having to mix cf with the js. > > So, is this as simple as: > > <cfset jsVar = "myCFVar"> > > and then using "jsVar" in the js? > > I haven't tried any of this or even searched > for an answer....just being lazy. > > Example? > > Rick > > -----Original Message----- > From: Michael Grant [mailto:mgr...@modus.bz] > Sent: Thursday, October 28, 2010 2:06 PM > To: cf-talk > Subject: Re: Question about using javascript in .cfm files... > > > I'll +1 that. I generally only use CF to set js vars at the top of the head > too. That way your js can stay pure js. > > > On Thu, Oct 28, 2010 at 12:04 PM, Rick Faircloth < > ric...@whitestonemedia.com > > wrote: > > > > > Interesting approach, Carl! > > Haven't thought about that. > > I'll definitely give that a try! > > > > Thanks for the tip! > > > > Rick > > > > -----Original Message----- > > From: Carl Von Stetten [mailto:cmvon...@hotmail.com] > > Sent: Thursday, October 28, 2010 11:19 AM > > To: cf-talk > > Subject: Re: Question about using javascript in .cfm files... > > > > > > Rick, > > > > I have shared CF variables with JavaScript too. What I usually do is > this: > > > > If I have to do any processes to define the CF variables, I put them at > the > > top of the document, above the <head> section. Then, in the <head> > section > > of my CFM page, I add a <cfoutput> inside a <script> tag and pass all of > > the > > desired CF variables into JavaScript variables. I make sure this is > > defined > > before I load any external JavaScript files and call any JavaScript > > functions. > > > > This way my JavaScript files retain their ".js" extension. > > > > HTH, > > Carl > > > > >I've been using js files as .cfm files > > >so I can intermix cf variables in the js. > > > > > >i.e., naming myJSFile.js, "myJSFile.js.cfm", instead. > > > > > >This seems to work fine, but I've run into an issue > > >that makes me wonder if this works in all cases as > > >a regular js file would. > > > > > >Here's the question: > > > > > >If I have a js function in a .cfm file, would the > > >declared function be defined by the browser > > >upon first entering a page as it would if the function > > >were in a .js file? > > > > > >e.g., should the function "checkUserFavorites": > > > > > >function checkUserFavorites(USERID) { > > > > > > blah, blah, blah > > > > > >be defined if the js were in a .cfm file as readily > > >as it would in a .js file? > > > > > >I keep running into a "checkUserFavorites is not defined" > > >for which I cannot track down the problem. > > > > > >I'm reaching for an answer at this point, because I can't > > >otherwise explain the error message otherwise, yet. > > > > > >Thanks for any feedback. > > > > > >Rick > > > > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:338654 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm