这个应该和你问的问题类似吧。
</style><br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/><table id="ta" width="350" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td bgcolor="#996633">&nbsp;</td>
    <td bgcolor="#234633"><button >  Clos</button></td>
    <td bgcolor="#0000FF">&nbsp;</td>
  </tr>
</table>
<script type="text/javascript">
var rePosition = function (o) {
//获取元素绝对位置
var $x = $y = 0;
do {
$x += o.offsetLeft;
$y += o.offsetTop;
} while ((o = o.offsetParent));
return { x : $x, y : $y };
};window.onload = function () {
var wc = document.getElementById("ta"), ing = false;
wc.onmouseover = function () {
if (!ing) {
ing = true;
alert("over");
}
};wc.onmouseout = function () {
var wc = this, e = window.event || e,
x = document.body.scrollLeft + e.clientX, y = document.body.scrollTop + e.clientY, p = rePosition(wc);
//alert(y);
if (x <= p.x || x >= (p.x + wc.offsetWidth) || y <= p.y || y >= (p.y + wc.offsetHeight)) {
alert("out");
ing = false;
}
};
};
</script>

解决方案 »

  1.   

    如果 (event.fromElement!=event.toElement) && (this.contains(event.toElement) )  
    就触发onmouseover事件一次
    如果 (event.fromElement!=event.toElement) && (this.contains(event.fromElement) ) 
    就触发onmouseout事件一次如果 (!this.contains(event.fromElement)) && (this.contains(event.toElement) ) 
    就触发onmouseenter事件一次如果 (!this.contains(event.toElement)) && (this.contains(event.fromElement) ) 
    就触发onmouseleave事件一次
    有关onmouseover和onmouseout
    http://jkisjk.spaces.live.com/blog/cns!758CACE25E89DD3B!397.entry
      

  2.   

    JK_10000(JK) muxrwc
    都不错,但是在firefox里就不好用了
      

  3.   

    希望大家继续关注这个问题,多层的onmouseout的问题
    老外的解决方法,在firfox下也不好用
    something like this may work for you 
    function myMouseOut() 

    if (!event.fromElement.contains(event.toElement) &&!document.getElementById('somedivId').contains(event.toElement)) 

    //do something on mouse out; 

    } Then call this js method onmouseout of the div and give the div some id. 
      

  4.   

    家风尚俭,天道酬勤ff里,
    用prototype实现一下contains,
    event.toElement/event.fromElement对应的是
    event.target/event.relatedTarget
      

  5.   

    刚少复制了个e嘿。。
    contains方法是不是检索是子对象用的??
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/><table id="ta" width="350" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td bgcolor="#996633">&nbsp;</td>
        <td bgcolor="#234633"><button >  Clos</button></td>
        <td bgcolor="#0000FF">&nbsp;</td>
      </tr>
    </table>
    <script type="text/javascript">
    var rePosition = function (o) {
    //获取元素绝对位置
    var $x = $y = 0;
    do {
    $x += o.offsetLeft;
    $y += o.offsetTop;
    } while ((o = o.offsetParent));
    return { x : $x, y : $y };
    };window.onload = function () {
    var wc = document.getElementById("ta"), ing = false;
    wc.onmouseover = function () {
    if (!ing) {
    ing = true;
    alert("over");
    }
    }; wc.onmouseout = function (e) {
    var wc = this, e = window.event || e,
    x = document.body.scrollLeft + e.clientX, y = document.body.scrollTop + e.clientY, p = rePosition(wc);
    //alert(y);
    if (x <= p.x || x >= (p.x + wc.offsetWidth) || y <= p.y || y >= (p.y + wc.offsetHeight)) {
    alert("out");
    ing = false;
    }
    };
    };
    </script>
      

  6.   

    muxrwc,我改成这样的在firefox怎么就不好用了呢,我的事件加在在层上了
    谢谢!隆重感谢几位帮忙
    function over_forshowclose(subobj){


     e = window.event || e,
    x = document.body.scrollLeft + e.clientX, y = document.body.scrollTop + e.clientY, p = rePosition(getObject(subobj));
    //alert(y);
    if (x <= p.x || x >= (p.x + getObject(subobj).offsetWidth) || y <= p.y || y >= (p.y + getObject(subobj).offsetHeight)) {
    getObject("xp").innerHTML=x;

    getObject(subobj).style.display="none"; }

    }
      

  7.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript">Object.reEvent = function () {
    //获取Event
    return window.event ? window.event : (function (o) {
    do {
    o = o.caller;
    } while (o && !/^\[object[ A-Za-z]*Event\]$/.test(o.arguments[0]));
    return o.arguments[0];
    })(this.reEvent);
    };var $P = {

    rePosition : function (o) {
    //获取元素绝对位置
    var $x = $y = 0;
    do {
    $x += o.offsetLeft;
    $y += o.offsetTop;
    } while ((o = o.offsetParent));
    return { x : $x, y : $y };
    }, reMouse : function () {
    //获取鼠标绝对位置
    var e = Object.reEvent();
    return {
    x : document.documentElement.scrollLeft + e.clientX,
    y : document.documentElement.scrollTop + e.clientY
    };
    }
    };window.onload = function () {
    var wc = document.getElementById("ta"), ing = false;
    wc.onmouseover = function () {
    if (!ing) {
    ing = true;
    alert("over");
    }
    }; wc.onmouseout = function () {
    var wc = this, mos = $P.reMouse(), pos = $P.rePosition(wc);

    if (mos <= pos.x || mos.x >= (pos.x + wc.offsetWidth) || mos.y <= pos.y || mos.y >= (pos.y + wc.offsetHeight)) {
    alert("out");
    ing = false;
    }
    };
    };
    </script>
    </head><body><br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/><table id="ta" width="350" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td bgcolor="#996633">&nbsp;</td>
        <td bgcolor="#234633"><button >  Clos</button></td>
        <td bgcolor="#0000FF">&nbsp;</td>
      </tr>
    </table>
    </body>
    </html>
      

  8.   

    if (mos < pos.x || mos.x > (pos.x + wc.offsetWidth) || mos.y < pos.y || mos.y > (pos.y + wc.offsetHeight)) {
    alert("out");
    ing = false;
    }
    注意把等号去掉。。
      

  9.   

    var itemcounts=5; //replace the num"4" to your num(itmes counts)
    Object.reEvent = function () {
    //获取Event
    return window.event ? window.event : (function (o) {
    do {
    o = o.caller;
    } while (o && !/^\[object[ A-Za-z]*Event\]$/.test(o.arguments[0]));
    return o.arguments[0];
    })(this.reEvent);
    };var $P = {

    rePosition : function (o) {
    //获取元素绝对位置
    var $x = $y = 0;
    do {
    $x += o.offsetLeft;
    $y += o.offsetTop;
    } while ((o = o.offsetParent));
    return { x : $x, y : $y };
    }, reMouse : function () {
    //获取鼠标绝对位置
    var e = Object.reEvent();
    return {
    x : document.documentElement.scrollLeft + e.clientX,
    y : document.documentElement.scrollTop + e.clientY
    };
    }
    };/*set position */
    function getposOffset(over_forshow, offsettype){
    var totaloffset=(offsettype=="left")? over_forshow.offsetLeft : over_forshow.offsetTop;
    var parentEl=over_forshow.offsetParent;
    while (parentEl!=null){
    totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft: totaloffset+parentEl.offsetTop;
    parentEl=parentEl.offsetParent;
    }
    return totaloffset;
    }
    /*close all the layer  of the details*/
    function CloseAlldiv(subobjstr){
      for(i=1;i<=itemcounts;i++)   
      {
      if  (("showdetails"+i)!=document.getElementsByTagName(subobjstr));
        getObject("showdetails"+i).style.display="none"
      }
        
    }function getObject(objectId) {
        if(document.getElementById && document.getElementById(objectId)) {
    // W3C DOM
    return document.getElementById(objectId);
        } else if (document.all && document.all(objectId)) {
    // MSIE 4 DOM
    return document.all(objectId);
        } else if (document.layers && document.layers[objectId]) {
    // NN 4 DOM.. note: this won't find nested layers
    return document.layers[objectId];
        } else {
    return false;
        }
    }
    function over_forshow(curobj, subobjstr){  
    var subobj=getObject(subobjstr)
    //var xpos=getposOffset(curobj, "left")-(subobj.offsetWidth-curobj.offsetWidth);
    var xpos=getposOffset(curobj, "left")
    var ypos=getposOffset(curobj, "top")+curobj.offsetHeight
    subobj.style.left=xpos-20+"px"
    //subobj.style.top=170+"px"
    subobj.style.top=ypos-380+"px"
    CloseAlldiv(subobjstr);subobj.style.width=250;
    subobj.style.height=410
    getObject(subobjstr).style.display="block"; 
    //new Effect(subobjstr,{w:250,h:420})

    //setTimeout(function(){new Effect(subobjstr,{w:250,h:420})},1)
         
     }function over_forshowclose(subobj){
    var wc = getObject(subobj), mos = $P.reMouse(), pos = $P.rePosition(wc);
    if (mos < pos.x || mos.x > (pos.x + wc.offsetWidth) || mos.y < pos.y || mos.y > (pos.y + wc.offsetHeight)) 


    {
       getObject(subobj).style.display="none";

    }

     
    }
      

  10.   

    http://www.cyberpowerdl.com/XG/Pop_up/js/default0605.html
    问题依然存在啊,大哥
      

  11.   

    感谢你!现在是鼠标只要过快,有可能不触发mouseout事件个别图层不隐藏
      

  12.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript">(function () {
    var event, html;

    if (window.MouseEvent) {

    event = window.MouseEvent.prototype, html = window.HTMLElement.prototype;

    event.__defineGetter__("fromElement", function () {
    return this.relatedTarget;
    });

    html.contains = function (obj) {
    var wc = this;
    do {
    if (obj == wc) return true;
    } while ((obj = obj.parentNode) && obj != document.body);
    return false;
    }

    }
    })();
    Object.reEvent = function () {
    //获取Event
    return window.event ? window.event : (function (o) {
    do {
    o = o.caller;
    } while (o && !/^\[object[ A-Za-z]*Event\]$/.test(o.arguments[0]));
    return o.arguments[0];
    })(this.reEvent);
    };window.onload = function () { var wc = document.getElementById("ta");
    wc.onmouseover = function () {
    var wc = this, e = Object.reEvent();
    if (!wc.contains(e.fromElement)) {
    alert("over");
    }
    }; wc.onmouseout = function () {
    var wc = this, e = Object.reEvent();
    if (!wc.contains(e.toElement || e.fromElement)) {
    alert("out");
    }
    };
    };
    </script>
    </head><body><br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/><table id="ta" width="350" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td bgcolor="#996633" id="1">&nbsp;</td>
        <td bgcolor="#234633" id="2"><button>  Clos</button></td>
        <td bgcolor="#0000FF" id="3">&nbsp;</td>
      </tr>
    </table>
    </body>
    </html>
      

  13.   

    我测那个就没有问题。。好郁闷的说。。那个relatedTarget真是怪异。。在over和out里竟然能起到相反的作用,我真是服了它们了。。
      

  14.   

    那个relatedTarget真是怪异。。在over和out里竟然能起到相反的作用
    -----
    在mouseOver时,主体target相当于event.toElement,
    在mouseOut时,主体target相当于event.fromElement,
    作用相反不算怪异.另,contains的prototype实现,
    以下代码来自meizz,仅供参考:
      var t=HTMLElement.prototype;
      t.contains=function(e){do if(e==this)return true;while(e=e.parentNode);return false;};
      

  15.   

    你真是个高手,其实你前几个版本做的也对,只是现在出来个新问题,鼠标移动过快,onmouseout事件就失效了,和位置无关
      

  16.   

    同志们到新帖子看看吧http://community.csdn.net/Expert/topic/5584/5584490.xml?temp=.9883386
    我快崩溃了