1 Reply Latest reply on Jul 11, 2007 8:06 AM by Fly Molo

    Java Script in external *.js files

    Walter_Saegesser Level 1
      I have some Java Script functions that I need to include in several topics. If I place them in the header section of a HTML file all works fine. But this is cumbersome because I have to copy all the functions to each topic file.
      Then I thought I could place the scripts into a separate "MyScripts.js" and include them using
      <script src="MyScripts.js" type="text/javascript"></script>
      But obviously this is not the way to do it. Nothing goes anymore. I also tried to place the file in the baggage. It does not make any difference whether I include the file in the Header- or Body-sections.
      Can anybody tell me how to properly use functions and variables from a script file? Thanks a lot.

      Walter

        • 1. Java Script in external *.js files
          Fly Molo Level 1
          It sounds like you know how to call a function, but need a way to distribute the '<script src="myscripts.js"...' portion of your code.

          Currently I do this by adding the javascript file to baggage (you did this) and then inserting the <script src="myscripts.js"...' bits to my topic templates (.HTT files). This works for my projects, though I don't know if it is applicable to yours.

          The contents of your external javascript file will need to (likely) look something like: