View Full Version : Question re external referencing of .js file

05-26-2006, 05:51 PM
Hi all,

I am trying to implement a javascript horizontal navigation menu across a website. The .js file is to be referenced as an external file and is located in the root folder.

I am able to reference the file from the index/home page which is also at the root level; however, when I am having difficulty referencing the file from a web page in a sub folder.

I am not a coder and actually this is my first javascript menu implementation attempt. I would greatly appreciate if you the forum members could assist me with the external referencing from a web page inside a sub folder. Thanks. - rk.

05-26-2006, 07:25 PM
You have 3 options

you can point directly to the root level folders by putting a forward slash before the folder name in your url. like so

<script language="JavaScript" type="text/javascript" src="/includes/mymenu.js"></script>

or you can hardcode in the entire path

<script language="JavaScript" type="text/javascript" src="http://www.mysite.com/includes/mymenu.js"></script>

or you can navigate through the directory structure by using ../ for each level you need to move down.

<script language="JavaScript" type="text/javascript" src="../includes/mymenu.js"></script>