Hi All,
My this seems to have been a busy forum of late! Looks like I've been missing a lot of fun. Haven't had much time these days for menu tinkering. I probably shouldn't admit it, but I'm still using v3 and am just now getting the chance to really play with v5 (

don't scold me John!). I've just been reading the latest posts to try to learn more about actually using v5... IMHO this forum is still the best learning resource, with so many people helping out, especially guys like John and Dave (thanks guys).
Anyway, I came across this thread and figured that, since v5 still has essentially the same built-in
gmobj() and
getMenuByName() functions that I co-opted for doing stuff like this in v3, a similar solution might present itself for v5. So I figured this might be a good place to get my v5 "tinkering" feet wet. (I hope you don't mind me jumping in Dave). v5 no longer has an
SDiv() function, so the approach is a little different, but only a little, from the v3 function earlier in this thread. Fortunately, the menu object styles in v5 seem to be a lot more accessible (at least to me). Anyway, it's late and I'm rambling... so here it is:
Code: Select all
function mm5_setMenuVisibility(menuName, visState)
{
menuObj = gmobj("menu" + getMenuByName(menuName));
if(ns4) {
menuObj.visibility = visState ? "show" : "hide";
}
else {
menuObj.style.visibility = visState ? "visible" : "hidden";
}
}
mm5_setMenuVisibility() takes two parameters:
menuName is the name of the menu you want to hide or show, passed as a string.
visState specifies the state of the menu style's visibility attribute: pass a
1 to
show the menu or a
0 to
hide it (true or false, respectively, will also work if you prefer). So, to hide a menu named "mainmenu", you'd call:
Code: Select all
mm5_setMenuVisibility('mainmenu', 0)
To show it again, you'd call:
Code: Select all
mm5_setMenuVisibility('mainmenu', 1)
George... I did a quicky test and it worked in IE6, NS7, and Opera 6.05 in Windows. The conditional
should, in theory, allow it to work in NS4, but it'd be wise to test first, if you care about NS4, because I didn't (and I don't!).
Hope that helps. Cheers all. Hope to be back soon.
Kevin