Click to See Complete Forum and Search --> : Aligning a div?


nickcrispini
11-04-2003, 06:59 PM
I have a menu, when you rollover a menu item a javascript function is called that displays a div. I can set the div to display left from the clients mouse position when they rolled over the menu item. However I want to display it in the other direction, 'right' from the clients mouse. Here's my function:

function displaySubMenu(divID)
{
myMouseX = event.clientX;
document.getElementById(divId).style.left=(myMouseX);
document.getElementById(divID).style.display='';
}

Any suggestions?

Thanks.

gil davis
11-04-2003, 09:24 PM
var wd = document.getElementById(divId).offsetWidth;
document.getElementById(divId).style.left = myMouseX + wd;
Or
document.getElementById(divId).style.right = myMouseX;