External JavaScript question.

Discussion in 'Web Design and Development' started by mattscott306, May 22, 2007.

  1. mattscott306 macrumors 68040

    mattscott306

    Joined:
    Jan 16, 2007
    #1
    Hey, I'm putting a really basic .js code in my pages, and rather than type up the code each time I want to just save it externally in an index. W3 Schools says you need to remove the <script> tags from the .js document, so I'm wondering if that means I should open up with:

    <type="text/javascript">
    or if I should open up with <script type="text/javascript">
    and just leave off the </script> at the end.
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    You don't open (or close) with any <> tags in the .js document. Just include what you were normally containing within the <script> tags. For example, your file might start with a "var xyz = 'test';" or perhaps a "function function_name (param) {..."
     
  3. mattscott306 thread starter macrumors 68040

    mattscott306

    Joined:
    Jan 16, 2007

Share This Page