New User - Paths to lower level files

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
KS100004
Beginner
Beginner
Posts: 5
Joined: Fri May 28, 2004 1:43 am
Contact:

New User - Paths to lower level files

Post by KS100004 »

I'm just getting started with DHTML and have almost no experience with JavaScript, so here goes. I have the following path defined on a menu:

aI("text=Blooming Grove;url=/data/bloominggrove/index.htm;");

When I try and test this it looks for C:\data\bloominggrove\index.htm

Obviously this can't be found. I assumed that the rules would be the same as HTML and it would look in the lower level under its current folder. It seems that this is incorrect, can anyone help with this problem?

Thank you,
Kevin
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Is the path setup on your local machine exactly the same as it would be on the server? You are using server-relative addressing (which is good), but if the path on the local doesn't match where the files are actually located (taking into account the root level), you get what you got - so to speak.
John
KS100004
Beginner
Beginner
Posts: 5
Joined: Fri May 28, 2004 1:43 am
Contact:

Post by KS100004 »

Thank you for the reply.

Yes, the path is how it would appear on the server. So why does it have a problem on my local box?

Kevin
User avatar
fredlongworthhighschool
Mega Advanced
Mega Advanced
Posts: 362
Joined: Fri Jun 27, 2003 11:34 am
Location: Manchester, England.
Contact:

Post by fredlongworthhighschool »

The url doesn't seem right to me. I would have thought it would be:

Code: Select all

aI("text=Blooming Grove;url=data/bloominggrove/index.htm;");
if it's in a folder below your JS data folder, or

Code: Select all

aI("text=Blooming Grove;url=../data/bloominggrove/index.htm;");
...if it's above.
Andy Davis
Web Designer & Smartboard Manager

Fred Longworth High School, Manchester, England.
KS100004
Beginner
Beginner
Posts: 5
Joined: Fri May 28, 2004 1:43 am
Contact:

Post by KS100004 »

Fred,

Perfect, that fixed it.

I guess the next question is why does the install.txt show:

The following is a sample menu that includes several menu items.

with(milonic=new menuname("mainmenu")){
style=myMenuStyle;
alwaysvisible=1;
left=10;
top=10;
aI("text=Home;url=/index.html;");
aI("text=About Us;url=/aboutus.html;showmenu=About Us;");
aI("text=Contact Us;url=/contactus.html;showmenu=contact;");
aI("text=Google;url=http://www.google.com/index.html;");
}

In order to build your menu up you could copy and paste the above, making
modifications as required.

Hence my mistake of placing "/" after the url= for a lower folder level.

Or do you need the "/" for individual files if they remain in the same level as the menu java?

Thank you,
Kevin
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

A typical server (not local) setup is something like /www/htdocs/(all my site files here). So even though your URL is http://www.me.com/, the real server location of the files is in the /htdocs/ directory - invisible to all.

So, if you do indeed place all your site files in /htdocs/ on the server, saying aI("url=/index.html;etc.), the server will start looking for this file from its root level (http://www.me.com/). Add /images/ to the site and aI("image=/images/us.gif;etc.) would be the call.

Server-relative (the /) always starts from the top and works its way down. Leave out the / and that means start from whatever directory I am in now and either look here or work my way down from here (depending on how you have coded it).

One of the biggies with this is in a deep directory structure where you have to, say, get an image from /images/ way back at the top. Without server-relative you'd be knee-deep in ../../../../images until you found it. With server-relative it's just /images/, regardless of where you are.

That's why the local structure must exactly match the server structure for it to work locally.

Hope that made at least a little sense, 'cause I just got up.
John
User avatar
stephen702
Super Advanced
Super Advanced
Posts: 77
Joined: Wed Jul 16, 2003 4:53 am
Location: Davis, CA
Contact:

Post by stephen702 »

The link syntax is probably only a bother to those of us who work off our own computer hard drives, and then upload changes to the server.

I can't use server paths for the files on my PC ("/new/index.html"), because it doesn't understand them. So I tried using relative links, like "new/index.html".

This worked fine on both my PC and on the server--as long as the menu was called from a page in the main directory. However, if the web page is in a subdirectory, I needed a separate menu_data.js file to take care of things.

Thus, in my menu_data2.js file (for pages in subdirectories), the above link would be changed to "../new/index.html". I also had to adjust for any images used in the menu. Cumbersome.

The only solution I know for my situation is to use an absolute link in all cases ("http://mysite.com/new/index.html"), so there need be only one menu_data.js file, no matter where the pages are located.
Post Reply