层的问题 关于 显示/隐藏
在下面的例子中,如果同时出现两个或两个以上的 A 连接,那么,当别人不去点击出现的层时,会导致几个层都不隐藏的问题,该如何解决?
**************请大家给予指点-----------
<html>
<script langugae='javascritp'>
function OverIt(obj){
eval("var mdata = document.all.div" + obj.substr(6,1) + ".style.display");
clearTimeout(mhandle);
if(mdata == "") return;
eval('document.all.div' + obj.substr(6,1) + '.style.left=window.event.x');
eval('document.all.div' + obj.substr(6,1)) ;
document.all.div2.style.display='';// (这句可以实现层的显示)
eval("document.all.div" + obj.substr(6,1) + ".style.display=''"); //(这句不可以,一样的结果)
}
var _setTimeout1 = window.setTimeout;
function _setTimeout(fRef, mDelay)
{
if(typeof fRef == 'function')
{
var argu = Array.prototype.slice.call(arguments,2);
var f = (function(){ fRef.apply(null, argu); });
return _setTimeout1(f, mDelay);
}
return _setTimeout1(fRef,mDelay);
}
var mhandle = null;
function OutIt(obj){
clearTimeout(mhandle);
mhandle = _setTimeout(OutIt1,100,obj);
}
function OutIt1(obj){
eval("document.all.div" + obj.substr(6,1) + ".style.display='none'");
}
function show_msg(mtd)
{
alert(mtd.innerHTML);
}
</script>
<body>
<div onmousemove='OverIt("A_Link2")' onmouseout='OutIt("A_Link2")' id=div2 style='position:absolute;display:none;'>
<table border=1 cellpadding='0' cellspacing='0' width=200>
<tr><td onclick='show_msg(this)'>罗技</td></tr>
</table>
<table border=1 cellpadding='0' cellspacing='0'>
<tr><td onclick='show_msg(this)'>福晶</td></tr>
</table>
</div>
<p><p><p>
<table width=180 border=1 cellpadding=0 cellspacing=0>
<tr><td width=30 height=22><div align=center><img src=images/topBar_bg.gif width=11 height=11></div></td>
<td width=150><a href='Product.asp?BigClassName=键盘系列' id='A_Link2' onmousemove='OverIt(this.id)' onmouseout='OutIt(this.id)'>键盘系列</a></td>
</tr>
</table>
<div onmousemove='OverIt("A_Link3")' onmouseout='OutIt("A_Link3")' id=div3 style='position:absolute;display:none;'>
<table border=1 cellpadding='0' cellspacing='0' width=200>
<tr><td onclick='show_msg(this)'>罗技</td></tr>
</table>
<table border=1 cellpadding='0' cellspacing='0'>
<tr><td onclick='show_msg(this)'>福晶</td></tr>
</table>
</div>
<p><p><p>
<table width=180 border=1 cellpadding=0 cellspacing=0>
<tr><td width=30 height=22><div align=center><img src=images/topBar_bg.gif width=11 height=11></div></td>
<td width=150><a href='Product.asp?BigClassName=鼠标系列' id='A_Link3' onmousemove='OverIt(this.id)' onmouseout='OutIt(this.id)'>鼠标系列</a></td>
</tr>
</table>
</body>
</html>