IE下用onmouseenter和onmouseleave事件
FF下没这问题

解决方案 »

  1.   

    (function (bool) {
    //兼容FF一些方法
    var html;if (bool) {html = window.HTMLElement.prototype;window.__defineGetter__("event", function () {
    //兼容Event对象
    var o = arguments.callee;do {if (o.arguments[0] instanceof Event) return o.arguments[0];} while (o = o.caller);return null;});Event.prototype.__defineGetter__("fromElement", function () {
    /*
    这里:
    onmouseover的时候relatedTarget为鼠标离开(onmouseout)的对象
    onmouseout的时候relatedTarget为鼠标当前(onmouseover)的对象
    */
    return this.relatedTarget;});html.contains = function (o) {
    do {
    if (o == this) return true;
    } while (o = o.parentNode);
    return false;
    };}})(/Firefox/.test(window.navigator.userAgent));window.onload = function () {var wc = document.getElementById("ta");
    wc.onmouseover = function () {
    var wc = this, e = window.event;
    if (!wc.contains(e.fromElement)) alert("over");
    };wc.onmouseout = function () {
    var wc = this, e = window.event;
    if (!wc.contains(e.toElement || e.fromElement)) alert("out");
    };
    };
      

  2.   

    楼上的,不要搞得吓人啊...在子DIV里面写onmouseout="onmo(event);"
    function onmo(event)
    {
    alert("onmouseover");
    if(event.preventDefault)
        event.preventDefault();
    event.cancelBubble = true;
    }
      

  3.   

    在事件开始执行时加event.cancleBuble=false
      

  4.   

    onmouseout不支持cancleBubble,各位注意
      

  5.   

    sorry,我的意思是 s_liangchao1s 得分~
      

  6.   


    <!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>
    </head><body>
    <div id="test" onmouseout="mouseout();" style="left:0px;top:0px;background:#CCCCCC;height:300px;width:300px">
        <div style="background:#333333; margin:50px 50px 50px 50px;height:200px;width:200px">
        </div>
    </div>
    </body>
    </html>
    <script>
    function mouseout(){
                    var test=document.getElementById("test");
    var e=window.event;
    var left=parseInt(test.style.left);
    var width=parseInt(test.style.width);
    var top=parseInt(test.style.top);
    var height=parseInt(test.style.height);
                    //利用事件触发时鼠标位置来防止该现象
    if(e.clientX > left && e.clientX < (left+width) && e.clientY > top && e.clientY < (top+height)){

    }else{
    alert("mouseout");
    }
    }
    </script>