SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast adear11's Avatar
    Join Date
    Oct 2003
    Location
    Richland MS
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using <link> tag with javascript

    I am working on a site with multiple pages using some of the same javascript functions. Is there a way that I can use the <Link> tag to use an external file. I know this should be possible, but I don't know how to go about linking the file and then using the funcitions. Can someone please tell me how to do this?

    Thanks.

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,426
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    You woun't use the <link> tag but the <script> tag like this:

    <script type="text/javascript" src="/pathtofile/javascript.js"></script>

    This goes in the <head> of your pages. Be sure to save your javascript functions in a separate file and give it a .js file extension so your server sends them to the browser correctly. Just call the functions within that javascript file as you would normally do, just be sure this line of code comes before you call those functions. You must use the closing </script> tag or it won't work. Also, don't put anything between the opening and closing tag.


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
  •