menu and javascript - should be simple

Results 1 to 2 of 2

Thread: menu and javascript - should be simple

  1. #1
    Join Date
    Dec 1969

    Default menu and javascript - should be simple

    Hi,<BR><BR>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):<BR>&#060;script language="JavaScript" src="menu.js"&#062;&#060;/script&#062;<BR>and some other js files as well.<BR><BR>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:<BR>&#060;script language="JavaScript" src="../menu.js"&#062;&#060;/script&#062;<BR><BR>etc.<BR>Is this how menus usually work?<BR>The paths have to be changed for each page?<BR><BR>Also, In the menu.js file itself, which is the file that contains the menu, there is the list of the items:<BR>var MENU_ITEMS =[<BR> ["item1", "Home",<BR> ["sub-item1", "aaa.htm"],<BR> ["sub-item2", "bbb.htm"],<BR> ["sub-item3", "ccc.htm"]]<BR><BR>etc.<BR>It works for one page, but when this file is included in another page, it does not work, as the page that calls it is located somewhere else, and the paths should be changed,<BR>as if it should be:<BR>var MENU_ITEMS =[<BR> ["item1", "../Home",<BR> ["sub-item1", "../aaa.htm"],<BR> ["sub-item2", "../bbb.htm"],<BR> ["sub-item3", "../ccc.htm"]]<BR><BR>etc.<BR><BR>I am sure it should not work this way and that I have missed something big.<BR><BR>Can someone pls help out, toexplain the concept of menus, without using frames?<BR>Thanks<BR><BR><BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Use absolute paths

    Or paths that are relative to the site root:<BR><BR>&#060;script type="text/javascript" src="/menu.js"&#062;&#060;/script&#062;<BR><BR>You wouldn&#039;t have "../images/" for all your images, would you?! It&#039;s the same - it&#039;s an attached item.<BR><BR>Craig.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts