English 中文(简体)
Change Coldfusion tags to leverage CDN hosted javascript libraries
原标题:

I ve been handed a Coldfusion application to support and I noticed that CF is adding script tags to certain pages. It appears these js files are supporting certain CF tags because I can t find any reference to the .js file(s) in .cfm file (or in any subsequent include files). The .js files are popular libraries which can be accessed via a CDN versus serving them from our web server. So my question is:

Can the CF tag or a Coldfusion setting be changed to update the .js url?

问题回答

Using the scriptsrc and cssSrc attributes

The scriptsrc attribute is useful if the JavaScript files are not in the default location. This attribute is required in some hosting environments and configurations that block access to the /CFIDE directory.

The default scriptsrc value is determined by the Default CFFORM ScriptSrc Directory setting on the Server Settings > Settings page of the ColdFusion Administrator. For cfform tags, the tag’s scriptsrc attribute takes precedence over this attribute.

You can use this attribute only if the cfajaximport tag is on a top-level page; that is, a page that the client directly requests. You cannot use it, for example, on a page that is specified in a cfwindow tag source attribute.

When you use the cfajaximport tag with a scriptsrc attribute, the specified directory must have the same structure as the /CFIDE/scripts directory. For example, if you specify scriptsrc="/resources/myScripts", the JavaScript files used by AJAX must be in the /resources/myScripts/ajax directory.

This attribute specifies the folder that contains the ColdFusion client-side files for all subsequent tags on the current page, not just for AJAX-based tags. Therefore, the directory tree must include all ColdFusion client-side files used by those tags. For example, if a cfform tag on the page is in Flash or applet format, include the CF_RunActiveContent.js file in the directory specified by the scriptsrc attribute.

You use the cssSrc attribute to specify the location of the CSS files required by ColdFusion AJAX features. This attribute overrides the scriptsrc/ajax/resources directory for the current page. Therefore, if all pages that use a custom scriptsrc directory also use a custom cssSrc directory, you do not have to include the ColdFusion AJAX CSS files in the scriptsrc directory tree.

Example:

<cfajaximport cssSrc="/collegeApp/application/cssFiles" 
    scriptsrc="/collegeApp/ajaxScripts" 
    tags="cftooltip, cfwindow">

reference: Adobe ColdFusion 9 * cfajaximport

The only .js files that CF should be including are for things like cfform or the cf ajax stuff, and they would be pointing to internal, CF specific .js files. I know the underlying cfajax stuff uses ExtJs, but I would imagine that it s a customized version of it so pointing to an external host would probably cause it to break anyway.

I m not sure what you re referencing when you mention the "popular libraries". Can you elaborate on that? I doubt you can replace any internal CF .js libraries with an external public library and have your CF code still work.

Henry points out the use of the cfajaximport tag, but according to the docs it s only for local .js files:

"Specifies the URL, relative to the web root, of the directory that contains the client-side script files used by ColdFusion."

Although, it would be interesting to see if a valid url would work.





相关问题
JQuery AJAX .load - flash chart doesnt load in IE

An IE issue has me completely stumped. I have a coldfusion page that uses JQuery s AJAX .load function to load in a new flash file that is generated by coldFusion s cfchart tag. This works completely ...

Best Coldfusion Library for OpenID [closed]

I am getting ready to start a project that requires using OpenID within Coldfusion 8. I have found a number of different options and was wondering what has worked the best, get s the most support, ...

Find ColdFusion Generated ID

Is there a way to find the elements generated by ColdFusion s <CFLayout> and <CFLayoutArea> tags? These tags: <cflayout type="tab" name="MyAccount"> <cflayoutarea name="...

ColdFusion COM error

I am upgrading from CF4.5 to CF8. Calls to COM dll s that used to work in version 4.5 now throw a "Complex object types cannot be converted to simple values.." error. The COM object has a few arrays ...

What s the best way to write engine-specific CFML code?

Sometimes it is necessary to write different code for Adobe ColdFusion vs Railo vs OpenBD, due to differences in implementation. Do people have a specific method that they use for this? For example, ...

热门标签