pop-up menus woe's

wxdqz

New Member
OK, so for now I have this all working, but there's a problem with the javascript that I still don't like. I used Dreamweaver MX, and here's what I did to make my pop-up menu:

For the main links, I just made rollover images that come standard with Dreamweaver. Then for the menus that pop out of these menu links I just made them into layers and made them invisible. So I can hide or show them by using these functions:

function show(object) { if (document.layers && document.layers[object] != null) document.layers[object].visibility = 'visible'; else if (document.all) document.all[object].style.visibility = 'visible'; }

function hide(object) { if (document.layers && document.layers[object] != null) document.layers[object].visibility = 'hidden'; else if (document.all) document.all[object].style.visibility = 'hidden'; }

OK, now for the problem. I wanted to make it so that when I roll on to a sub-menu, it would keep that main menu link highlighted so you know which link this sub-menu is coming from. Seems simple enough.

So I just used the MM_swapImage() function that comes with Dreamweaver:
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

So I added this code to that submenu layer:
onMouseOver="MM_swapImage('main_link','','images/mainlink_on.gif',1);"

onMouseOut="MM_swapImage('main_link','','images/mainlink_off.gif',1);"

Now, for some reason, this messes with the rest of my code that uses the MM_swapImage function. I guess there's something wrong with using it on two objects at the same time. So I made my own separate function to handle changing the main_link picture.

Is there any way I can use Dreamweavers script to do this?
 
Back
Top