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: Archived Topics for the old Version 3.0 JavaScript Menu
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:43

Can I have the .js files in another location?


Poster: skyfire
Dated: Wednesday September 18 2002 - 8:29:03 BST

Can I have the .js files in another location to the main entry point .html file?

I have tried putting absolute links in:

<SCRIPT language=JavaScript src="http://www-cgi.monash.edu.au/cgi-bin/cgiwrap/mlhol1/menu_array.js" type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript src="http://www-cgi.monash.edu.au/cgi-bin/cgiwrap/mlhol1/mmenu.js" type=text/javascript></SCRIPT>

but this causes the menus to not appear at all. The only way I have managed to get them to appear is to have the <script> tags as:

<SCRIPT language=JavaScript src="menu_array.js" type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript src="mmenu.js" type=text/javascript></SCRIPT>

Is there anyway around this problem?


Poster: skyfire
Dated: Wednesday September 18 2002 - 9:06:25 BST

I've managed to fix that problem, the menu appears now except the arrow.gif file doesn't appear once I've followed a link. I have changed the menu_array.js to have an absolute link to the image but it didn't help.

suggestions?


Poster: ctreeves __at__ attbi.com
Dated: Thursday September 19 2002 - 4:42:38 BST

I have my menus on their own page. Then I use that page as an include anywhere I want to have the menus.

This will likely solve the multiple menu problem too.


Poster: Scott
Dated: Tuesday September 24 2002 - 22:37:33 BST

I use the a fixed link to the arrow in my array and it works fine..

eg.
"http://www.server.com/images/arrow.gif", // Sub Menu Image (Leave this blank if not needed)

Using menu across multiple pages in different locations?


Poster: biographie
Dated: Thursday October 17 2002 - 7:50:30 BST

I am new to this, but I am slowly learning quite abit about menus. This is really awesome, but I have a problem.

As mentioned above, I was trying to use the script to the menus on other pages I had created, and did not see them. Once I changed the relative file path to the .js files, it started to locate and load the menus. However, it does not seem to find any of the image files. And it doesn't make sense to me as to why?!

I know that I can edit the path and filename in the menu_array.js file. But that file does not move. It is located in the same directory as the gif files. But the only way I can see the gif images is to have my html page located in the same file as everything else. This doesn't seem right to me?! Please, I need help, this is somewhat holding up my website development.

Thanks,
Scott


Poster: Scott
Dated: Thursday October 17 2002 - 9:20:26 BST

The path to the images is dependant upon the location of the page, as the page loads the javascript .js file is loaded into memory as a part of that page, therefore any image reference held within the code must be correct for anywhere the page is loaded.

eg. if you have the below folder structure to your site

[] (root)
|
|-index.htm
|-menu.js
|-menu_arry.js
|-[] images
|- arrow.gif


Your image path for the arrow (as used by index.htm) would be images/arrow.gif.

However if a link from index.htm went to page products.htm located in the folder products (see below) then the location of arrow.gif would no longer be correct.

[] (root)
|
|-index.htm
|-menu.js
|-menu_arry.js
|-[] products
|- products.htm
|-[] images
|- arrow.gif

The correct route to arrow.gif from products would be ../images/arrow.gif

The easiest way to get arround this is to use an absolute address for the location of the graphic.

eg. If your URL is http://www.mydomain.com/
THe arrow.gif file would be located at http://www.mydomain.com/images/arrow.gif this location would never change no matter where you are in the site..

Hope this makes sence and helps.
Scott

That works!


Poster: biographie
Dated: Thursday October 17 2002 - 16:08:53 BST

Thanks Scott! That works like a charm!! :D

I would not usually mind looking at the code to figure out what I need to do. But that mmenu.js file is just a beast to look at.

Maybe you can answer this quick question for me. Does it create an issue my having multiple menu_array and mmenu.js files located in the website? Let me explain, I want to setup my website for different screen resolutions and different languages (english, spanish, german). I would initially have two folders (800 and 1024), and under each of those folders, I would have three others (de, en, sp). That gives me effectivly six folders/website setups.

I am assuming I want to place a menu specific to each website in its own locaiton. Only one menu would be used at anytime, but each website would need its own menu_array.js file. Do I just make a specific menu_array.js file for each site, and always reference to a single copy of mmenu.js; or do I make a copy of both in each website folder?


Poster: bobwill
Dated: Thursday October 17 2002 - 16:46:07 BST

You might want to consider setting up a variable to save you a lot of typing when you enter the long "url' address.

Inside of the menu_array.js file you could create a variable (sample)

urladdr="http://www.mydomain.com"

Then instead of typing "http://www.mydomain.com/images/arrow.gif"
you could enter

"urladdr+/images/arrow.gif"

This is very useful when you have to change addresses. Saves a lot of typing.

one slight change to your url variable post


Poster: biographie
Dated: Thursday October 17 2002 - 17:32:35 BST

thanks bobwill! that helps big time, but i found one little thing, or maybe i am doing something wrong:

when you go to use the variable urladdr, it needs to be outside the quotes:

urladdr+"/images/arrow.gif" not "urladdr+/images/arrow.gif"

i know it is a small thing, but to someone getting started with programming code, it may not make sense as to why it is like this. granted i am still new, but i think i am learning fast. :)

thanks,
scott

wait, i think i still have a problem with the url variable


Poster: biographie
Dated: Thursday October 17 2002 - 17:49:15 BST

okay, maybe i got ahead of myself, what do you do about this situation:

When you call the images to be used for each submenu item in the addmenu function:

"<img src=urladdr+/google_icon.gif border=0>&nbsp;Google.com", "http://www.google.com"

how in the world do you get the src to reconize just the urladdr+ as a variable in the file that it needs to go get. I tried just putting quotes around "/google_icon.gif", but that doesn't seem to work.

Is this one of those situations that I have no choice but to hard-code the full address into the src (that kind of sucks)?

<img src=http://www.yourdomain.com/images/google_icon.gif border...

I really like the idea of making a variable shortcut to keep the already large code file somewhat streamlined.

Thanks,
Scott


Poster: bobwill
Dated: Thursday October 17 2002 - 22:01:29 BST

Your are right about the position of the quotes not being around the variable. I am not a javascript programmer so I can't answer you next question. Hopefully someone will have the answer. I have been looking in a Java programmers manual, but have not come across the answer. I will keep checking or until someone else has answer. \


Good Luck