Ok, I have a number of javascript functions that I use to validate forms etc and I want to stick them all in an external .js file.

I have tried calling this file using:

<script language="JavaScript" src="file.js" type="text/javascript"></script>

but I keep getting errors and the functions do not work.

Can anyone shed some light onto how I can solve my problem?

    I've never seen anyone specify the argument "type" in a <script> tag. Try stripping it down to everything that's necessary and testing. That means just having <script src="file.js"></script>

    What's that give?

      same here ... I've never seen the type attribute of the Script tag used ... whats it do?

        The type tag is recomended by the W3C if I am not mistaken! And if you don't use it your file will not be valid! 😉

          Problem solved. Just a stupid typo.

          I got a bit confused cos the error said that the error was on line 4, but the mistake that I made was on line 3.

          Thanks everyone!

            Jebster's correct, the type="text/javascript" attribute is necessary to make the page valid. (At least in XHTML 1.0+, I don't bother with HTML anymore 🙂 )

            From the DTD (1.0 Strict):

            <!-- script statements, which may include CDATA sections -->
            <!ELEMENT script (#PCDATA)>
            <!ATTLIST script
              id          ID             #IMPLIED
              charset     %Charset;      #IMPLIED
              type        %ContentType;  #REQUIRED
              src         %URI;          #IMPLIED
              defer       (defer)        #IMPLIED
              xml:space   (preserve)     #FIXED 'preserve'
            
            

            (taken from http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict)

              Write a Reply...