SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot bo diddly's Avatar
    Join Date
    Nov 2002
    Location
    uk - worcester
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question how do i use external js file

    Hi all,

    i am using dreamweaver mx to build a site with css, however the client wants the graphical buttons to have image swaps on mouseover.

    my question is - if i use behaviours to achieve this effect can i take the script code out and save it as an external file and link to it? or do i need a custom script and link to that instead?

    any help for this non-programmer would be great.

    thanx rog
    You're not drunk if you can lie on the floor without holding on

    www.idezign.me.uk
    www.theonlinediary.com

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Take everything between the <script> and </script> and save that as a text file ending in .js . Then use <script type="text/javascript" src="script.js"></script> to insert it into the page.

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Apr 2003
    Posts
    4,095
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's more or less accurate, Dan, but as far as I know you shouldn't have "<script>" tags in the external JS file. Otherwise, the output (if included) would look like this:

    HTML Code:
    ...
    <script type="text/javascript" src="/Scripts/Test.JS">
    <script>
    ...
    </script>
    </script>
    ...
    See what I mean?

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I specifically said to take everything BETWEEN the <script> and </script> tags and put those in the file.

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Apr 2003
    Posts
    4,095
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oops, sorry, Dan. I was in a hurry and misunderstood your post.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •