View Full Version : AnyLink Drop Down Menu- customize bg color

03-16-2005, 06:04 PM
The script is: http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm

Question: Is there any way to customize the script so that each Menu Option has a different bg color? There is a way to set a bgcolor, however, it is set once and for all options. I can create each sub-menu topic as an image with the correct bgcolor that I want, but for ease of maintenace, it would be easier to just have to update text and not an image.


05-24-2005, 11:41 PM
Yes, it's possible to put individual background colors in the menus. You have to edit the script. I've gotten it to work in both IE and FF, but it's something of a hack, so use it at your own caution. Here we go.

First, pass in the desired color in the onMouseOver:

onMouseover="dropdownmenu(this, event, menu0, '130px', '#BF8718')"
In this case, I've added the #BF8718 into the array.

Next you need to add some code into into the AnyLink script itself. Add the variable, menucolor at the end of the variable array in the dropdownmenu function, like so:

function dropdownmenu(obj, e, menucontents, menuwidth, menucolor)
Then we need to rewrite the div tag with the new bg color, so add the code below as the first two lines in the dropdownmenu function like I've done below:

newText = '<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menucolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>';
document.getElementById("changeDropmenudiv").innerHTML = newText;

That should be it.


02-06-2006, 09:59 AM

I tried this out with http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm.

I did exactly with the instructions above, but it's not working...

Somebody has another idea how doing this?


11-29-2007, 10:27 PM
I found this old thread when searching the forums for an answer to the same problem.

My solution, if it helps anyone out there: