Won't that just make it null instead of undefined when the "url:" line of the included .js file runs? Not that I have a better answer.
On Wed, Nov 17, 2010 at 2:20 PM, Michael Grant <mgr...@modus.bz> wrote: > > Define your var outside of the function. > > <script type="text/javascript"> > > var jsActiveWebrootDirectory; > > $(document).ready(function() { > > jsActiveWebrootDirectory = '#cfActiveWebrootDirectory#'; > > }); > > > </script> > > > On Wed, Nov 17, 2010 at 2:20 PM, Rick Faircloth <r...@whitestonemedia.com > >wrote: > > > > > I'm trying to set a js var using cf in the head of a file, then use > > that js var in an externally called js file... > > > > > > If I'm using this in the head of a .cfm page to set a js var with cf: > > > > <cfset cfActiveWebrootDirectory = > > application.activeWebrootDirectory> > > > > <cfoutput> > > > > <script type="text/javascript"> > > > > $(document).ready(function() { > > var jsActiveWebrootDirectory = > > '#cfActiveWebrootDirectory#'; > > }); > > > > </script> > > > > </cfoutput> > > > > and the following in the js file, "01-processEmailProperty.js": > > > > url: '' + jsActiveWebrootDirectory + > > > > > '/modules/emailProperty/00-propertyEmailProcessing.cfc?method=mEmailProperty > > &returnFormat=json' > > > > The line "url" line immediately above is part of the js file that is > > referenced in the .cfm > > mentioned at the top of this message as an external js file like this: > > > > <script type="text/javascript" > > src="modules/emailProperty/01-processEmailProperty.js"></script> > > > > Why would the var, "jsActiveWebrootDirectory", always be "undefined" in > the > > file containing the "url" line above when the 01-processEmailProperty.js > > function is called? > > > > > > Does the question make sense? > > I can reword it if it's not clear... > > > > 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:339326 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm