views:

87

answers:

1

Hi All,

I've created this simple script to check if jQuery is loaded

<cfoutput>
<cfif GetPageContext().getCFOutput().getBuffer().findStringNoCase("jquery.js") eq -1>
    <script type="text/javascript" src="jquery.js"></script>
</cfif>

<script>
    $(document).ready( function() {
        $("##theValue").val("the replacement");
    });
</script>

<input type="Text" name="theValue" id="theValue" value="the value">
</cfoutput>

the whole page is surrounded by cfoutput

is there any better solution?

+1  A: 

Eapen's comment is the best answer.

"I agree with Ken Redler - just use this approach - coldfusioning.com/index.cfm/2010/7/9/… i.e. if (typeof jQuery === 'undefined') document.write(""); " - eapen

Aaron Greenlee
which one is the savest, using document.write or add as <head> child element?
tsurahman
This is the best way in my opinion: http://www.coldfusioning.com/index.cfm/2010/7/9/Load-jQuery-From-Google-Without-Risk-of-Breaking-Your-Site
Aaron Greenlee