7 Replies Latest reply on Jul 15, 2016 1:06 PM by KomputerMan.com

    Including a javascript file using javascript

    KomputerMan.com Level 1

      Just playing around with including javascript templates into my CF code when I came across this issue.

       

      I have two files I'm testing with.  The javascript file I want to include is called KDL.js.  The contents are listed here:

      <script language="javascript">
        function KDL_Test(MyString) {
        var MsgString = MyString + "KDL Rocks";
        alert(MsgString);
        }
      </script>
      

       

      The other template is called KDL.cfm, and it's contents:

      <CFINCLUDE TEMPLATE="kdl.js"> 
      
      <script language="javascript">
        KDL_Test("I am here. ");
      </script>
      

       

      This works fine as I get my alert window whenever I execute the code.

       

      What I don't understand is why doesn't the javascript alert window get called when I use javascript to include the javascript template?

      <script language="JavaScript" type="text/javascript" src="kdl.js"></script>
      
      <script language="javascript">
        KDL_Test("I am here. ");
      </script>
      

       

      This code doesn't generate any error messages but I don't get the popup window either like I did with the first include.  Thoughts???