I have some javascript menu code that works just fine from a separate directory. But, when I try to call the same .js files from within the same directory, it won't see the files.
The following works from another directory:
script type="text/javascript"> var vbImgPath="../00-Menu-Files/"
But, if I do this from within the same folder, how would I do it?
THE SOLUTION (edited this in after much experimentation):
I experimented A LOT!!! There is only ONE solution that ultimately worked:
"../00-Menu-Files/"
The SAME thing as from the other directory! Pretty strange that there is no other way to call this from within its own directory. But I cannot find another alternative that actually works.
-
Maybe you'd use:
script type="text/javascript"> var vbImgPath="00-Menu-Files/"
You may want to make this work anywhere by using absolute urls with a / at the beginning and the full path afterwards, ie.
script type="text/javascript"> var vbImgPath="/00-Menu-Files/"
Whether this works or not depends on your site's directory structure.
James Musser : Nope, no go. Tried them both. Dang!dylanfm : By referencing all things (images in img tags, urls in anchors, scripts and so on) with their absolute path (/images/logo.png or /javascripts/script.js), things will always be found. It's much better than ../ing around the place and making things dependent on where they are called. -
Tried both of those already, didn't work...
dylanfm : What's the directory structure like? -
I came up with a solution, but would prefer to keep the file in the same directory. I created a subfolder in the same directory with the image files for the menus called "MenuPHP", and then did this:
script type="text/javascript"> var vbImgPath="../00-Menu-Files/"
to push it up a directory and specify the name of the above directory. Solved the problem, but added another directory to the path. At least the files are all in the same vicinity, which was what I was after.
If anyone knows how to specify the same directory, please advise.
DrG : you mean var vbImgPath="../MenuPHP/" -
Usually directories are like this:
../ one up
/ root directory
./ The current directory. However not adding anything to the front should mean the same.
-
Also tried another solution which now seems to work, but didn't work earlier for some reason:
script type="text/javascript"> var vbImgPath="../00-Menu-Files/"
Same command as the other directory... oh well, it works!!!
0 comments:
Post a Comment