PDA

View Full Version : Anylink drop down - 2 different heights on same page?



roblynch
09-25-2008, 10:46 AM
1) Script Title: AnyLink Drop Down Menu

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

3) Describe problem: I'm a complete novice here, so I'm hoping for some helpful advice from someone a lot cleverer than me!

I'm using the anylink drop down menu, and in the code I've added a "+3" to the following line:

dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+3+"px"

so that the dropdown appears a few pixels below my link/image. Trouble is, I'd like to have another link on my page where the menu appears above this second image link. I can amend the line of code to say -165 instead of +3 but this (obviously) changes every link.

I realise that this may be too difficult to do (and therefore may not be answered!), but if anyone knows how this can be done I'd appreciate any help :)

ddadmin
09-25-2008, 06:47 PM
Actually, in this case, it's fairly simple to do. :) First, replace the original dropdownmenu() inside the script with the below version instead:


function dropdownmenu(obj, e, menucontents, menuwidth, offset){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+(offset||0)+obj.offsetHeight+"px"
}

The above adds a new "offset" parameter you can use in your HTML, for example:


<a href="default.htm" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, menu1, '150px', -5)" onMouseout="delayhidemenu()">Web Design</a>

roblynch
09-27-2008, 12:31 PM
ddadmin - brilliant! Can't tell you how grateful I am for your help - thanks very much!