michelledebeer
Programmer
I have a pop-up menu system that uses layers to show the different sections.
I have noticed on other web sites that when the mouse-pointer exits the layer, the menus are hidden automatically.
In my script I have solved this by just setting a timeout to 5 second if there has been no activity whatsoever on the webpage (see function hideAll). I don't really like this approach.
Does anyone know how to create this onMouseOut event.
Please let me know if you need to know anything else.
Here is the code:
var remember = new Array();
var remember2 = new Array();
var checkIt;
var DHTML = (document.getElementById || document.all || document.layers);
function show(name,lvl,obj)
{
if (!DHTML) return;
checkTimeOut();
if (remember[lvl] && remember[lvl] == name) return;
if (remember[lvl])
{
hideAll(lvl);
}
if (name)
{
var x = getObj(name);
x.visibility = 'visible';
}
remember[lvl] = name;
if (obj.parentNode) y = obj.parentNode;
else if (obj.parentElement) y = obj.parentElement;
else return;
if (y.className) return;
y.className = 'over';
if (remember2[lvl]) remember2[lvl].className = '';
remember2[lvl] = y;
}
function hideAll(lvl)
{
for (i=remember.length - 1;i>=lvl;i--)
{
if (remember)
{
var x = getObj(remember);
x.visibility = 'hidden';
}
remember = null;
if (remember2)
{
remember2.className = '';
remember2 = null;
}
}
}
function checkTimeOut()
{
if (checkIt) clearTimeout(checkIt);
checkIt = setTimeout('hideAll(1)',5000);
}
function getObj(name)
{
if (document.getElementById)
{
return document.getElementById(name).style;
}
else if (document.all)
{
return document.all[name].style;
}
else if (document.layers)
{
return document.layers[name];
}
else return false;
}
I have noticed on other web sites that when the mouse-pointer exits the layer, the menus are hidden automatically.
In my script I have solved this by just setting a timeout to 5 second if there has been no activity whatsoever on the webpage (see function hideAll). I don't really like this approach.
Does anyone know how to create this onMouseOut event.
Please let me know if you need to know anything else.
Here is the code:
var remember = new Array();
var remember2 = new Array();
var checkIt;
var DHTML = (document.getElementById || document.all || document.layers);
function show(name,lvl,obj)
{
if (!DHTML) return;
checkTimeOut();
if (remember[lvl] && remember[lvl] == name) return;
if (remember[lvl])
{
hideAll(lvl);
}
if (name)
{
var x = getObj(name);
x.visibility = 'visible';
}
remember[lvl] = name;
if (obj.parentNode) y = obj.parentNode;
else if (obj.parentElement) y = obj.parentElement;
else return;
if (y.className) return;
y.className = 'over';
if (remember2[lvl]) remember2[lvl].className = '';
remember2[lvl] = y;
}
function hideAll(lvl)
{
for (i=remember.length - 1;i>=lvl;i--)
{
if (remember)
{
var x = getObj(remember);
x.visibility = 'hidden';
}
remember = null;
if (remember2)
{
remember2.className = '';
remember2 = null;
}
}
}
function checkTimeOut()
{
if (checkIt) clearTimeout(checkIt);
checkIt = setTimeout('hideAll(1)',5000);
}
function getObj(name)
{
if (document.getElementById)
{
return document.getElementById(name).style;
}
else if (document.all)
{
return document.all[name].style;
}
else if (document.layers)
{
return document.layers[name];
}
else return false;
}