Hi Alex,
Thank you for the posting again. As you indicated you want to create a
drop menu that works like the one in IE.
For your convenience and information. I performed further research and
testing on this issue and I am providing you with the following sample code
to create a drop menu.
<HTML>
<HEAD>
<TITLE>Drop Menu</TITLE>
</HEAD>
<body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>
<p>
<p> <SCRIPT LANGUAGE="JavaScript" >
var IsDroped =false;
function mouseout()
{
window.event.srcElement.style.color = 'white';//when the mouse moves
out,it turns white
}
function mouseover()
{
window.event.srcElement.style.color = 'red';//when the mouse moves
over,it turns red
}
function doMenu(MenuID)
{
var CurMenu = document.all(MenuID);
//To avoid flashing, if the drop menu has been displayed,then cancel
redrawing.
if (IsDroped==true)
{
window.event.cancelBubble = true;
return false;
}
window.event.cancelBubble = true;
TempMenu = CurMenu;
//calculate the location of the drop menu
x = window.event.srcElement.offsetLeft +
window.event.srcElement.offsetParent.offsetLeft;
x2 = x + window.event.srcElement.offsetWidth;
y = pad.offsetHeight;
CurMenu.style.top = y;
CurMenu.style.left = x;
CurMenu.style.clip = "rect(0 0 0 0)";
CurMenu.style.display = "block";
//delay 2 ms and display the menu,in order to guarantee that the
"ToolbarMenu.offsetHeight" has its value
// ,avoiding the situation that when the mouse moves from the main
menu to the drop menu ,the drop menu disappears.
window.setTimeout("showMenu()", 2);
return true;
}
function showMenu()
{
y2 = y + TempMenu.offsetHeight;
TempMenu.style.clip = "rect(auto auto auto auto)";
IsDroped =true;//the drop menu has been displayed
}
function hideMenu()
{
//If the mouse moves in the range of drop menu area ,then the drop menu
won't hide
cY = event.clientY + document.body.scrollTop;
if (cY>=y && cY<y2 && event.clientX >= (x+5) && event.clientX <= x2 ||
cY>1 && cY<y && event.clientX >= (x+5) && event.clientX <= x2-10)
{ window.event.cancelBubble = true; return;}
//hide
TempMenu.style.display = "none";
window.event.cancelBubble = true;
IsDroped =false;
}
</SCRIPT>
<p> <DIV ID='menu'
STYLE='position:absolute;background-color:white;width:100%;top:0;left:0;'>
<DIV ID='pad' STYLE='position:relative;height:20;width:100%;font:bold
11pt ??;background-color:#007FFF;color:white;'>
<A TARGET='_top' TITLE='' ID='pad1'
onmouseout="mouseout(); hideMenu();" onmouseover="mouseover();
doMenu('idpad1');">
Menu1 </A>
<SPAN style="color:white"> </SPAN>
<A TARGET='_top' TITLE='' ID='pad2'
onmouseout="mouseout(); hideMenu();" onmouseover="mouseover();
doMenu('idpad2');"
onclick="window.event.returnValue=false;">
Menu2 </A>
</DIV>
</DIV>
<SPAN ID='idpad1'
STYLE='display:none;position:absolute;width:140;background-color:#007FFF;pad
ding-top:0;padding-left:0;padding-bottom:20;z-index:9;'
onmouseout='hideMenu();'>
<HR STYLE='position:absolute;left:0;top:0;color:white' SIZE=1>
<DIV STYLE='position:relative;left:0;top:8;'>
<A ID='pad1' STYLE='text-decoration:none;cursor:hand;font:bold 11pt
??;color:white'
HREF='11.htm' TARGET='_top'
onmouseout="mouseout();" onmouseover="mouseover()">
SubMenu1-1 </A><BR>
<A ID='pad1' STYLE='text-decoration:none;cursor:hand;font:bold 11pt
??;color:white'
HREF='12.htm' TARGET='_top'
onmouseout="mouseout();" onmouseover="mouseover()">
SubMenu1-2 </A><BR>
<A ID='pad1' STYLE='text-decoration:none;cursor:hand;font:bold 11pt
??;color:white'
HREF='13.htm' TARGET='_top'
onmouseout="mouseout();" onmouseover="mouseover()">
SubMenu1-3 </A>
</DIV>
</SPAN>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<SPAN ID='idpad2'
STYLE='display:none;position:absolute;width:140;background-color:#007FFF;pad
ding-top:0;padding-left:0;padding-bottom:20;z-index:9;'
onmouseout='hideMenu();'>
<HR STYLE='position:absolute;left:0;top:0;color:white' SIZE=1>
<DIV STYLE='position:relative;left:0;top:8;'>
<A ID='pad2' STYLE='text-decoration:none;cursor:hand;font:bold 11pt
??;color:white'
HREF='21.htm' TARGET='_top'
onmouseout="mouseout();" onmouseover="mouseover()">
SubMenu2-1</A><BR>
<A ID='pad2' STYLE='text-decoration:none;cursor:hand;font:bold 11pt
??;color:white'
HREF='22.htm' TARGET='_top'
onmouseout="mouseout();" onmouseover="mouseover()">
SubMenu2-2</A><BR>
<A ID='pad2' STYLE='text-decoration:none;cursor:hand;font:bold 11pt
??;color:white'
HREF='23.htm' TARGET='_top'
onmouseout="mouseout();" onmouseover="mouseover()">
SubMenu2-3</A><BR>
<HR STYLE='color:white' SIZE=1><!--???-->
<A ID='pad2' STYLE='text-decoration:none;cursor:hand;font:bold 11pt
??;color:white'
onclick="parent.close()"
onmouseout="mouseout();" onmouseover="mouseover()">
Exit</A>
</DIV>
</SPAN>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> <!--???????-->
</p>
</BODY>
</HTML>
Hope the above information and suggestion helps and answers your question.
If anything is unclear, please let me know.
Sincerely,
Cherry Qian
MCSE2000, MCSA2000, MCDBA2000
Microsoft Partner Online Support
Get Secure! -
www.microsoft.com/security
====================================================
When responding to posts, please Reply to Group via your newsreader so
that others may learn and benefit from your issue.
====================================================
This posting is provided AS IS with no warranties, and confers no rights.