PDA

View Full Version : External Javascript for Nested Pages



mbockstruck30
06-27-2006, 05:49 PM
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

cbulmer
06-27-2006, 08:36 PM
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.

mbockstruck30
06-27-2006, 09:12 PM
Thanks. I'll try that.