[thelist] DHTML menu linking problem

miinx lists at miinx.com.au
Sat Oct 26 09:49:01 CDT 2002


unruly mongrel wrote:
> a crucial under/oversight:  the links in the javascript coding are
> restricted to a particular folder.  I.e., the links don't adapt
> depending on
> what page in what folder the menu is installed in.

essentially what you need to do is check what level directory you're in
before you call the nav code, and set a variable for the "rootpath" that
you can then prepend to any links/urls called in the nav code.

one way to do this:

if your nav code is in the base directory at, say,
http://www.yoursite.com/ and you've got further subdirectories
http://www.yoursite.com/dir1/ and http://www.yoursite.com/dir1/dir2/
then before your nav code you'd run this:

var currLoc = window.location.toString();
var rootPath = "";

if (currLoc.indexOf("dir2") != -1)
     rootPath = "../../"
else if (currLoc.indexOf("dir1") != -1)
     rootPath = "../"


then in your js nav code you need to include rootpath in every relevant
link, e.g.:

someurl = rootPath + "rest/of/the/link.js"

hth :)
karen
-------
Miinx Design & Development
e :: karen at miinx.com.au
p :: 0413.880.302
w :: www.miinx.com.au





More information about the thelist mailing list