Below is a script I found at http://javascript.internet.com/ for a
cascading menu. The script works great but there is one thing that I
would like modified. BecauseI am just learning javascript, I did not
want to try to modify the code without a little help. When you place
the mouse over the menu bar, this script calls the function to show the
menu. I would like it modified to hide the menu when the mouse is
removed. Please help. The full code is below:
function InitMenu()
{
var bar = menuBar.childre n
for(var i=0;i < bar.length;i++)
{
var menu=eval(bar[i].menu)
menu.style.visi bility = "hidden"
bar[i].onmouseover = new Function("ShowM enu("+bar[i].id+")")
var Items = menu.children
for(var j=0; j<Items.length ; j++)
{
var menuItem = eval(Items[j].id)
if(menuItem.men u != null)
{
menuItem.innerH TML += "<Span
Id="+menuItem.i d+"_Arrow class='Arrow'>4 </Span>"
//var tmp = eval(menuItem.i d+"_Arrow")
// tmp.style.pixel Left =
menu.getBoundin gClientRect().R ight //- tmp.offsetWidth - 15
FindSubMenu(men uItem.menu)}
if(menuItem.cmd != null)
{
menuItem.onclic k = new
Function("Do("+ menuItem.id+")" ) }
menuItem.onmous eover = new
Function("highl ight("+Items[j].id+")")
}
}
}
function FindSubMenu(sub Menu)
{
var menu=eval(subMe nu)
var Items = menu.children
for(var j=0; j<Items.length ; j++)
{
menu.style.visi bility = "hidden"
var menuItem = eval(Items[j].id)
if(menuItem.men u!= null)
{
menuItem.innerH TML += "<Span
Id="+menuItem.i d+"_Arrow class='Arrow'>4 </Span>"
// var tmp = eval(menuItem.i d+"_Arrow")
//tmp.style.pixel Left = 35
//menuItem.getBou ndingClientRect ().right - tmp.offsetWidth - 15
FindSubMenu(men uItem.menu)
}
if(menuItem.cmd != null)
{
menuItem.onclic k = new
Function("Do("+ menuItem.id+")" ) }
menuItem.onmous eover = new
Function("highl ight("+Items[j].id+")")
}
}
function ShowMenu(obj)
{
HideMenu(menuBa r)
var menu = eval(obj.menu)
var bar = eval(obj.id)
bar.className=" barOver"
menu.style.visi bility = "visible"
menu.style.pixe lTop = obj.getBounding ClientRect().to p +
obj.offsetHeigh t + Bdy.scrollTop
menu.style.pixe lLeft = obj.getBounding ClientRect().le ft +
Bdy.scrollLeft
}
function highlight(obj)
{
var PElement = eval(obj.parent Element.id)
if(PElement.has ChildNodes() == true)
{ var Elements = PElement.childr en
for(var i=0;i<Elements. length;i++)
{
TE = eval(Elements[i].id)
TE.className = "menuItem"
}
}
obj.className=" ItemMouseOver"
window.defaultS tatus = obj.title
ShowSubMenu(obj )
}
function Do(obj)
{
var cmd = eval(obj).cmd
window.navigate (cmd)
}
function HideMenu(obj)
{
if(obj.hasChild Nodes()==true)
{
var child = obj.children
for(var j =0;j<child.leng th;j++)
{
if (child[j].className=="ba rOver")
{var bar = eval(child[j].id)
bar.className=" Bar"}
if(child[j].menu != null)
{
var childMenu = eval(child[j].menu)
if(childMenu.ha sChildNodes()== true)
HideMenu(childM enu)
childMenu.style .visibility = "hidden"
}
}
}
}
function ShowSubMenu(obj )
{
PMenu = eval(obj.parent Element.id)
HideMenu(PMenu)
if(obj.menu != null)
{
var menu = eval(obj.menu)
menu.style.visi bility = "visible"
menu.style.pixe lTop = obj.getBounding ClientRect().to p +
Bdy.scrollTop
menu.style.pixe lLeft = obj.getBounding ClientRect().ri ght +
Bdy.scrollLeft
if(menu.getBoun dingClientRect( ).right window.screen.a vailWidth )
menu.style.pixe lLeft = obj.getBounding ClientRect().le ft -
menu.offsetWidt h
}
}