Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

menus and javascript

Status
Not open for further replies.

avivit

Technical User
Jul 5, 2000
456
IL
Hi,

I found a great menu, but encountering a probelm when trying to In order to use the menu, I have to include the javascript file from each page on my website (unless I misunderstood):
<script language="JavaScript" src="menu.js"></script>
and some other js files as well.

But when I insert it to another page, as is, it does not work as the path is different (for example:page is located in sub directory), so IT SHOULD BE:
<script language="JavaScript" src="../menu.js"></script>

etc.
Is this how menus usually work?
The paths have to be changed for each page?

Also, In the menu.js file itself, which is the file that contains the menu, there is the list of the items:
var MENU_ITEMS =[
["item1", "Home",
["sub-item1", "aaa.htm"],
["sub-item2", "bbb.htm"],
["sub-item3", "ccc.htm"]]

etc.
It works for one page, but when this file is included in another page, which is locatd in antother directory,it does not work, as the page that calls it is located somewhere else, and the paths should be changed,
as if it should be:
var MENU_ITEMS =[
["item1", "../Home",
["sub-item1", "../aaa.htm"],
["sub-item2", "../bbb.htm"],
["sub-item3", "../ccc.htm"]]

etc.

I am sure it should not work this way and that I have missed something big.

Can someone pls help out, toexplain the concept of menus, without using frames?
Thanks
 
var MENU_ITEMS =[
["item1", "Home",
["sub-item1", "../aaa.htm"],
["sub-item2", "../bbb.htm"],
["sub-item3", "../ccc.htm"]]


must do...

Known is handfull, Unknown is worldfull
 
When dealing with any kind of include file (through using server-side includes to linking in style sheets and javascript files) you will need to take paths into consideration.

I develop any sites that require include files so that the same path can be used for all pages. This means a flatter file structure - not a bad thing in itself.

In the same way that people use an images directory at the top level of a web site, I add an includes directory... and handle my links relative to that (similar for css and js directories).

Hope that explains a little,
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top