Results 1 to 3 of 3

Thread: External Javascript for Nested Pages

  1. #1
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default External Javascript for Nested Pages

    Hi. This may be a stupid question and hopefully a simple answer (i searched but couldn't find anything). I have a couple external .js files for a css dropdown menu and a random image rotator. The files work fine when applied to the homepage (images link to the images folder; menu links to respective pages within folders).

    The problem is when I apply the .js files to pages within other folders on the site, the files do not work. I have to create a duplicate .js files with a "../" before each link or image within the file. I have to do this for each level of folders within the site (which can go up to 4 or 5 extra .js files).

    Is there a trick so that each .js file can be applied to all the pages without creating multiples?

    Please let me know if this is confusing. Thanks.
    Edit/Delete Message

  2. #2
    Join Date
    Jun 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ok, what you need here is, say a folder called scripts, in the same folder that the index page is in. (highest level) Then you need to recall the script with a different url each time.e.g.

    Main Folder
    First Folder
    First Page - "../Scripts/Script.js"
    Scripts
    Script.js
    Second Folder
    Third Folder
    Second Page - "../../Scripts/Script.js"

    You get the idea.
    This way, there is only one copy of the file, and this lowers requests to the server, because the single file is stored in the cache, unless the browser is told not to store it there.

  3. #3
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks. I'll try that.

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
  •