PDA

View Full Version : Pop-up, not pop-down menus



guttyguppy
12-21-2005, 01:04 AM
I'm using this code on my site:
http://www.dynamicdrive.com/dynamicindex1/dropmenuindex.htm

but I want to modify it so that the menu pops above the link. One thing to keep in mind is that I may have menus of different lengths, but the all must share the same bottom value so they start at the same point above the link. I've pored over the code for a while, but I'm a little lost at this point. Can anyone offer any advice? Thanks!

jscheuer1
12-21-2005, 05:58 AM
Find this line:


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

Change it to this:


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

If you would like the menus to drop down when there isn't enough room for them to drop up, find these lines:


if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge

Change them to this:


if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) {//up no good?
edgeoffset=dropmenuobj.y+(0.4*obj.offsetHeight)+dropmenuobj.offsetHeight-topedge
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure) //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight

guttyguppy
12-21-2005, 03:05 PM
Thank you! That worked perfectly.