Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Thursday February 8 2018 - 06:02:18

Problems with relative URL's

Poster: heinrichegg
Dated: Sunday November 30 2003 - 13:58:53 GMT

If you move a html-file from one folder to another folder either up or down in the hierarchy Dreamweaver fixes the path for all links - also the path to the milonic scrips, EXCEPT the two in this code:

<script language=JavaScript>
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=scripts/ver_5_0/mmenuns4.js><\/scr"+"ipt>");
else _d.write("<scr"+"ipt language=JavaScript src=scripts/ver_5_0/mmenudom.js><\/scr"+"ipt>"); </script>

These are not changed and that causes problems.

This is also a problem when you use Templates and creates html-pages for different places in the folder-structure. All other links are automatically fixed, but not these two?

This is probably because Dreamweaver don't recognize these two paths as links since they are embedded into java code.

Any solution?


Poster: John
Dated: Sunday November 30 2003 - 17:05:33 GMT

You are correct, DW does not recognize those as valid links.

From your message, I have to assume you are moving the 3 menu code files around. If so, and if all your pages are on the same server (domain), why move the code files?

For instance, one of my sites is the Student Affairs Intranet at ASU West located at Under this are a few directories (/staff/, /tech/, /edit/, etc.), with the possibility of others being added at any time. All of my menu files are located in /templates/menu5/ (and they stay there!). The JS calls to the menu are located in one single file that I call using an include statement. This called file looks like this...

Code: Select all

<script language="JavaScript" src="/sai/templates/menu5/milonic_src.js" type="text/javascript"></script>   
<script language="JavaScript" type="text/javascript">
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=/sai/templates/menu5/mmenuns4.js><\/scr"+"ipt>");      
else _d.write("<scr"+"ipt language=JavaScript src=/sai/templates/menu5/mmenudom.js><\/scr"+"ipt>");</script>
<script language="JavaScript" src="/sai/templates/menu5/xp_data.cfm" type="text/javascript"></script>

Note the leading / in the links to the various files. This is server-relative addressing (the root server location being

The call to the JS call file is...

Code: Select all

<cfinclude template="/sai/templates/Nav_Standard.cfm">

Don't worry - that's a ColdFusion include - use whatever you need.

OK, that one include gets the JS call file regardless of where the page it's on is located in the directory structure, and the JS calls get the menu files the same way - doesn't matter where the call came from (finally - the point of all this!).

So - leave your menu files in one place, adjust your calls to conform to the server-relative addressing, and move stuff around all you want!

Still confused!

Poster: heinrichegg
Dated: Monday December 1 2003 - 13:36:32 GMT

Thank you for all your help. I did try to put the call-script-code as you said in one separate file with ending .cfm. Then I put the <cfinclude... code in the header of the html-documents, but with no luck?

I asume that to be able to use this method the webserver where my site is stored has to have coldfusion server installed?

Are there any other include method I can use?

I am not moving the three code files around. They are stored in one folder by themselves all the time as you do.

The problems occur if I want to move web-pages up or down in the directory-structure. For example - I would like to move ceartain webpages into separate subfolders to make the website more structured. Or if I copy a webpage and use it as an template for a new document that is stored in another niveau of the directory-structure.

When I create new documents based on DM templates this is really a big problem. I have one template that I use for all webpages. In this template I have put the calls to the menu-scripts. When I make a new webpage based on this template I would like to store this new page wherever I want, but now I can't store any pages over or below the directory nivau that is defined in the template. I could of course make one template for documents stored on the root with this call


one template for the first subdir - ../scripts/mmenuns4.js

one template for the second subdir - ../../scripts/mmenuns4.js

Hovewer, this is not a very practical way of doing it.

I also tried /scripts/mmenuns4.js in my pages, but that doesn't work? Will this work on the webserver when I publish the pages? Do I need to run a personal webserver to solve this?

As you understand I am not a java or cf-programmer...


Poster: John
Dated: Monday December 1 2003 - 14:54:03 GMT

Remember, I said...
jgillett wrote:Don't worry - that's a ColdFusion include - use whatever you need.

You can't use a ColdFusion statement on a non-CF site. Also, you can't just stick a .cfm on the end of a file unless you're on a CF server. If you're using .js now, stick with it. Sorry that wasn't more clear.

The "typical" include for a Unix server is...

Code: Select all

<!--#include file="/sai/templates/Nav_Standard.js" -->

Note the syntax carefully. There are NO spaces in the beginning as you would see in a typical comment (which this looks very much like), but there IS a space towards the end (.js" -->). This is important or it won't work. If you don't know the correct syntax check with your host to find out what they require (different languages/servers require different syntax).

This will get you away from the ../, ../../ junk that causes trouble and takes time.

heinrichegg wrote:I also tried /scripts/mmenuns4.js in my pages, but that doesn't work? Will this work on the webserver when I publish the pages?

No, According to what you wrote earlier, the path to your menu code is...

Therefore, you need...

Code: Select all



No solution yet!

Poster: heinrichegg
Dated: Sunday December 7 2003 - 22:45:42 GMT

Thanks again for your help!

First to clear up a detail: When I wrote /scripts/mmenuns4.js it was just ment as an example of the leading /. Of course I wrote /scripts/ver_5_0/mmenuns4.js in my own code but with no luck?

My ISP supports ASP so I installed IIS 5.1 (the one that is included in WinXPPro) and made a virtual directory for my website. Then I used the include statement for ASP.

I made a file with this code:

<script language=JavaScript>
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=/scripts/ver_5_0/mmenuns4.js><\/scr"+"ipt>");
else _d.write("<scr"+"ipt language=JavaScript src=/scripts/ver_5_0/mmenudom.js><\/scr"+"ipt>");

Then, in the header of the asp-files I put this code:
<!-- #include file="/scripts/ver_5_0/" -->

This does not work: The leading / is not allowed in the <!-- #include file="/scripts/ver_5_0/" --> statement.

For an asp-document in the root these two statements work:
<!-- #include file="./scripts/ver_5_0/" --> and
<!-- #include file="scripts/ver_5_0/" -->

When I use the last statement DM fixes the relative path if I move the file to another location down in the directory structure. So this is OK!

However, the paths inside the file does not work with the leading / either. If I use relative paths as ../ they are still not updated and therefore I am not any closer to a solution.

If I put the script_call.asp in the same folder as the three menu scripts I thought I could write this code:
<SCRIPT language=JavaScript src="milonic_src.js" type=text/javascript></SCRIPT>
<script language=JavaScript>
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=mmenuns4.js><\/scr"+"ipt>");
else _d.write("<scr"+"ipt language=JavaScript src=mmenudom.js><\/scr"+"ipt>");

But no success.
It seems that what matters is where the .asp file is located relative to the menu scripts. The .inc file does not "see" the three menu-files by itselves before it is included. It looks for the scripts after it is included in the .asp file and then the relative path has to be correct compared to the .asp and not the .inc.

Strange that I can't get the leading / to work? Even when I now am running my own locally webserver?

Any solution to this?

May be I can put this code
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=mmenuns4.js><\/scr"+"ipt>");
else _d.write("<scr"+"ipt language=JavaScript <SCRIPT language=JavaScript src="/scripts/ver_5_0/milonic_src.js" type=text/javascript></SCRIPT>src=mmenudom.js><\/scr"+"ipt>");
into a separate javascript which I call from the htm-documents as a <SCRIPT language=JavaScript src="script_call.js" type=text/javascript></SCRIPT>

I will try this now.