onfunction for entire submenu?

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
blah45
Beginner
Beginner
Posts: 1
Joined: Thu Aug 05, 2004 5:32 pm

onfunction for entire submenu?

Post by blah45 »

Is there a way to apply the same mouseover/mouseout function for an entire submenu, rather than calling it in each submenu item?

Example at: http://www.dreamindigital.com/oak/

I have it working so that for each section of the menu, a different rollover image fades in and is displayed somewhere else on the page. To do this, I use the on/offfunction in the main menu like this:

Code: Select all

aI("text=alumni;showmenu=Alumni;onfunction=JSFX.fadeIn('side','side3');offfunction=JSFX.fadeOut('side');");
But, when you go to the submenu of "Alumni" (and the others too) it needs to keep displaying that same rollover image so I also have to declare the on/offfunctions for all the "Alumni" submenu items like this (and they are all the same for that submenu):

Code: Select all

with(milonic=new menuname("Alumni")){
style=menuStyle;
aI("text=link 1;url=/link1;onfunction=JSFX.fadeIn('side','side3');offfunction=JSFX.fadeOut('side');");
aI("text=link 2;url=/link2;onfunction=JSFX.fadeIn('side','side3');offfunction=JSFX.fadeOut('side');");
aI("text=link 3;url=/link3;onfunction=JSFX.fadeIn('side','side3');offfunction=JSFX.fadeOut('side');");
aI("text=link 4;url=/link4;onfunction=JSFX.fadeIn('side','side3');offfunction=JSFX.fadeOut('side');");
}
However, this causes the image to flash each time you go to another menu submenu item. I've made it less noticable by drastically reducing the fade out time but that makes it slow and annoying. A better fix would be to just declare the on/offfunction once for the entire submenu! Is there a way to do this?

Thanks.
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

onfunction and offfunction are also style properties. Declare them there.

See http://milonic.com/forum/viewtopic.php?t=2981.
John
Post Reply