Can I have the .js files in another location?

Please note that official support for this menu version has now ceased. There are still plenty of users, though, and the forum is still running. Some of our long-time users may be able to help you out.
Post Reply
skyfire
Beginner
Beginner
Posts: 3
Joined: Sun Sep 08, 2002 5:57 am
Contact:

Can I have the .js files in another location?

Post by skyfire »

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/cg ... u_array.js" type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript src="http://www-cgi.monash.edu.au/cgi-bin/cg ... 1/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?
skyfire
Beginner
Beginner
Posts: 3
Joined: Sun Sep 08, 2002 5:57 am
Contact:

Post by skyfire »

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?
ctreeves@attbi.com
Beginner
Beginner
Posts: 9
Joined: Sun May 19, 2002 7:24 pm

Post by ctreeves@attbi.com »

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.
User avatar
Scott
Advanced
Advanced
Posts: 26
Joined: Thu Aug 08, 2002 10:03 am
Location: U.K.

Post by Scott »

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)
The lobsters are coming!!!
biographie
Advanced
Advanced
Posts: 17
Joined: Thu Oct 17, 2002 7:41 am

Using menu across multiple pages in different locations?

Post by biographie »

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
User avatar
Scott
Advanced
Advanced
Posts: 26
Joined: Thu Aug 08, 2002 10:03 am
Location: U.K.

Post by Scott »

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
The lobsters are coming!!!
biographie
Advanced
Advanced
Posts: 17
Joined: Thu Oct 17, 2002 7:41 am

That works!

Post by biographie »

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?
User avatar
bobwill
Mega Advanced
Mega Advanced
Posts: 229
Joined: Tue Oct 01, 2002 3:03 pm
Location: Kansas
Contact:

Post by bobwill »

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.
biographie
Advanced
Advanced
Posts: 17
Joined: Thu Oct 17, 2002 7:41 am

one slight change to your url variable post

Post by biographie »

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
biographie
Advanced
Advanced
Posts: 17
Joined: Thu Oct 17, 2002 7:41 am

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

Post by biographie »

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
User avatar
bobwill
Mega Advanced
Mega Advanced
Posts: 229
Joined: Tue Oct 01, 2002 3:03 pm
Location: Kansas
Contact:

Post by bobwill »

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
Post Reply