Javascript Directory

I have a javascript code that works fine from a separate directory. But, when I try to call the same .js files from the same directory, it doesn't see the files.

The following works from another directory:

script type = "text / javascript"> var vbImgPath = "../00-Menu-Files/"

But if I do it from one folder, how would I do it?

SOLUTION (edited this after a lot of experimentation):

I've experimented a lot! Ultimately only one solution works:

"../00-Menu-Files/"

The same as in the other directory! Oddly enough, there is no other way to call this from your own directory. But I cannot find any other alternative that actually works.

0


source to share


4 answers


Typically, directories look like this:

../one up



/root directory

./ Current directory. However, not adding anything to the front should mean the same thing.

+5


source


Perhaps you will use:

script type="text/javascript"> var vbImgPath="00-Menu-Files/"

      

You might want to make this work anywhere, using absolute urls with / at the beginning and full path later, i.e.



script type="text/javascript"> var vbImgPath="/00-Menu-Files/"

      

Whether this will work or not depends on your site's directory structure.

0


source


I came up with a solution, but would prefer to save the file in the same directory. I created a subfolder in the same directory with image files for the menu called "MenuPHP" and then did this:

script type = "text / javascript"> var vbImgPath = "../00-Menu-Files/"

to push it to a directory and give the name of the specified directory. Solved the problem but added a different path to the path. At least the files are in the same neighborhood and that was what I was.

If anyone knows how to point to the same directory, please let us know.

0


source


Also tried another solution which now works but for some reason doesn't work before:

script type = "text / javascript"> var vbImgPath = "../00-Menu-Files/"

Same command as in the other directory ... well it works !!!

0


source







All Articles