View Full Version : Anchoring DHTML menu?
yodamusa
01-07-2003, 06:56 AM
Hi:
I found a rather good DHTML menu, though need a little help customizing it. The script in question is: http://www.dynamicdrive.com/dynamicindex1/popit.htm
I was wondering if there's an easy way to anchor this particular DHTML script, so the menu drops down directly beneath the link in question, rather than where the mouse cursor is.
Thanks for the help,
LonelyKing
01-08-2003, 02:41 PM
All right... in the showmenu function, you'll find an area that has stuff like:
menuobj.contentheight = blahblahblah
menuobj.contentwidth = blahblahblah
Right before that, insert this code:
if(!ie4)
{
var tar = e.target;
while(tar.nodeType != 1)
tar = tar.parentNode;
}
This is for Netscape/Mozilla... since their event handling is retarded. Right after the menuobj.contentwidth you'll see two more variables, eventX and eventY. Change those lines to read:
eventX = (ie4) ? event.srcElement.offsetLeft : tar.offsetLeft;
eventY = (ie4) ? event.srcElement.offsetTop + event.srcElement.offsetHeight : tar.offsetTop + tar.offsetHeight;
One more thing you need to change. About three lines up from the bottom of the function, change the line right below the 'else' to read:
menuobj.thestyle.top=ie4? document.body.scrollTop+eventY : ns6? window.pageYOffset+eventY : eventY
And I guess that's what you're looking for. This will work in IE, Netscape and Mozilla for sure. Not so sure about other browsers, but hey.
yodamusa
01-10-2003, 08:08 AM
Thanks for the help! I'll try and examine your suggestions more closely later in the day.
Thx.
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.