View Full Version : Switch Menu

01-25-2008, 08:26 PM
1) Script Title: switch menu

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/switchmenu.htm

3) Describe problem: Here is my site, (http://canadatrack.com/TorontoTrack)I am prepping it for a release at the end of the weekend! First off, I know its a mess without CSS implimented and CSS tables would peobably be better and more efficient, but I just don't know how to do that all effectively right now and am trying to learn the pluses and minuses of using css over tables etc.

I have 2 problems, I've searched on the forum to see if anyone has had the same issues as me and some have but not been replied to yet. Essentially I have two requests/issues.

1) Using this script, when I have a menu item heading once clicked I would like it to expand to the sub menu but ALSO go to a URL pointed at an Iframe.. so it would function like:

Menu title ---> http://....
--->sub 1 ---> http://...
--->sub 2 ---> http://...

2) second issue is I have an image dividing my menu, because ou cannot seem to have two menus on one page, so I made it look like there are 3 menues divided by an image http://canadatrack.com/TorontoTrack

This seems to work in IE 7.0 BUT doesnt work in FF! Why would this be?

Finally, if anyone can help me clean up my page a little with tips on CSS and placing some of my page in an external file that would be more than appreciated.. please get back to me ASAP I will be checking this thread too often!


01-25-2008, 09:55 PM
Regarding #1, if I understood you correctly, you can always just attach a function to the header onClick code to do what you wish. Using the code from the demo for example:

<div class="menutitle" onclick="SwitchMenu('sub1'); dothat('http://google.com')">Site Menu</div>

Where dothat() would be your custom function, in this case loading an IFRAME with a specific URL:

function dothat(url){

Regarding #2, right now there's no easy way to have multiple Switch Menus on the same page. You can have a single menu with many menu headers and sub contents, but these react dependently, with one closing when the other opens. Accordion Menu (http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu.htm) supports multiple instances.

BTW, please note that your page is currently in violation of our usage terms, since the credit notice doesn't appear inline on the page. Please reinstate the credit notice: http://www.dynamicdrive.com/notice.htm

01-25-2008, 10:07 PM
Yes I will place that information in the files as soon as I get it CSS compliant, I was just trying to clean the HTML up a little to try and sort things out. I will definately place the header back in there.

okay I think I understand what you are trying to say, unsure how to implient it but I will do my best.

Secondly, its made as one menu however there is an image in that menu which is messing things up in FF... Do you see any other way of adding that image in there (to look like a seperate box) without changing scripte?

Thanks for your help it is greatly appreciated, I will be working on the CSS and placing that info back into my page immediately

01-27-2008, 12:02 AM
I've got the function working in IE but not working n FF..

function menutitle(url){

<div class="menutitle" onclick="SwitchMenu('sub4'); menutitle'http://youtube.com')">Cool links</div>

what is IE reading that FF isnt?

also my origional script wasnt from DD thats why it didnt have the tags, it was from http://javascript.internet.com/navigation/expanding-menu.html

02-07-2008, 08:42 PM
For one thing, you'll want to make sure your menutitle function is called correctly. Currently you have:


Where it should be:


You're missing the opening parenthesis.