Hi,
I'm trying to develop a drop down menu bar - where there is a row of buttons across the top of the page, and when you move the mouse over one of them a sub-menu drops down, lined up with the button. I am having trouble getting the sub-menu to line up with the button, especially if the window size changes.
The relevant bit of the function to draw the drop-down menu is :
function Menu(current) {
m = document.getElementById("menu-" + current);
boxes = document.getElementById(current);
boxes.style.offsetLeft = m.offsetLeft;
boxes.style.offsetTop = m.offsetBottom;
boxes.style.visibility = "visible";
boxes.style.width = m.width;
}
A sample menu button defn:
<td ID="menu-utilities" width="120" align="center"
onMouseOver="Menu('utilities'); document.images[0].src='utilbut2.gif';"
onMouseOut="Timeout('utilities'); document.images[0].src='utilbut1.gif';">
<img src="utilbut1.gif">
</td>
A sample menu:
<div ID="utilities" STYLE="position: absolute; visibility: hidden; ">
<table width="120" border="0" cellspacing="0" cellpadding="0">
<tr height="5" width="120">
<td height="5" align="center" ID="ut1" valign="top"
onMouseOver= ......
onMouseOut = .......
onClick = ......
>
<img src="item1but1.gif">
</td>
</tr>
...... other <tr>.s for other menu items similarly.
</table>
</div>
The offsetTop/offsetLeft settings do not seem to work, ie they do not take the value from the menu button and apply it to the drop-down menu.
Second problem is, the height attributes of both buttons and menus are also being ignored, and the resultant table items are always displayed slightly deeper than the .gif files. Any ideas why ?
Thanks in advance,
Pinpoint
I'm trying to develop a drop down menu bar - where there is a row of buttons across the top of the page, and when you move the mouse over one of them a sub-menu drops down, lined up with the button. I am having trouble getting the sub-menu to line up with the button, especially if the window size changes.
The relevant bit of the function to draw the drop-down menu is :
function Menu(current) {
m = document.getElementById("menu-" + current);
boxes = document.getElementById(current);
boxes.style.offsetLeft = m.offsetLeft;
boxes.style.offsetTop = m.offsetBottom;
boxes.style.visibility = "visible";
boxes.style.width = m.width;
}
A sample menu button defn:
<td ID="menu-utilities" width="120" align="center"
onMouseOver="Menu('utilities'); document.images[0].src='utilbut2.gif';"
onMouseOut="Timeout('utilities'); document.images[0].src='utilbut1.gif';">
<img src="utilbut1.gif">
</td>
A sample menu:
<div ID="utilities" STYLE="position: absolute; visibility: hidden; ">
<table width="120" border="0" cellspacing="0" cellpadding="0">
<tr height="5" width="120">
<td height="5" align="center" ID="ut1" valign="top"
onMouseOver= ......
onMouseOut = .......
onClick = ......
>
<img src="item1but1.gif">
</td>
</tr>
...... other <tr>.s for other menu items similarly.
</table>
</div>
The offsetTop/offsetLeft settings do not seem to work, ie they do not take the value from the menu button and apply it to the drop-down menu.
Second problem is, the height attributes of both buttons and menus are also being ignored, and the resultant table items are always displayed slightly deeper than the .gif files. Any ideas why ?
Thanks in advance,
Pinpoint