事件冒泡,用onmouseleave替换onmouseout,我本机的ie8没问题,
然后用jquery来bind,火狐和ie8都没问题,可是朋友用ie6和ie7试了下都不行哦,还是事件冒泡
不是说ie都支持onmouseleave吗?为毛就ie8可以,ie6、7都不行呢

解决方案 »

  1.   

    呵呵,肯定是ie8的时候把这个bug修复了呗!!
      

  2.   

    正解
    考虑到兼容性,一般就用onmouseout。
      

  3.   

    有木有人有好方法阻止事件冒泡的
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
     </HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    window.onload=function(){
    var p=document.getElementById("test"); p.onmouseout=function(){p.style.display="none"};
    }
    //-->
    </SCRIPT>
     <BODY>
    <div id="test" style="background-color:Red">
    <a  class="b">aaaaaaaaaaaaa</a><br />
    <a  class="b">aaaaaaaaaaaaa</a><br />
    <a  class="b">aaaaaaaaaaaaa</a><br />
    <a  class="b">aaaaaaaaaaaaa</a><br />
    <a  class="b">aaaaaaaaaaaaa</a><br />
    </div>
     </BODY>
    </HTML>鼠标移出div时隐藏该div。可惜现在鼠标移到a标签时div也隐藏了
    在线等大虾
      

  4.   

    http://www.cnblogs.com/QLeelulu/archive/2008/12/03/1346869.html
    楼主看看那这个
      

  5.   

    呵呵,我本来用的就是这个博客中的第三种方法,刚又试了第二种方法。
    结果是ie8、火狐没问题,ie6、tt、搜狗都不行
      

  6.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <head>
      <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset="gb2312" /> 
      <style type="text/css">
      a
      {
      font-size: 12px;
      text-decoration: none;
      color: Green;
      margin:10px 5px;
      }
      </style>
    <script type="text/javascript">
     
    function contextMenuOperation(event) {
      var e = event || window.event;
      e.returnValue = false;
      var img = document.getElementById("img_Person");
      img.contextmenu = function() { return false; }
      var div = document.getElementById("div_ContextMenu");
      var left = e.clientX;
      var top = e.clientY;
      div.style.display = "block";
      div.style.position = "absolute";
      div.style.left = left + "px";
      div.style.top = top + "px"; 
    }
    function contextMenu(event) {
      var e = event || window.event;
      var img = document.getElementById("img_Person");
      img.contextmenu = function() { return false; }
      var div = document.getElementById("div_ContextMenu");
      if(test(div,e)){
      var left = e.clientX;
      var top = e.clientY;
      div.style.display = "none";
      div.style.position = "absolute";
      div.style.left = left + "px";
      div.style.top = top + "px";
      e.returnValue = false;
    }
    }if(typeof(HTMLElement)!="undefined")   // 给firefox定义contains()方法,ie下不起作用
      {  
          HTMLElement.prototype.contains=function(obj)  
          {  
              while(obj!=null&&typeof(obj.tagName)!="undefind"){ //通过循环对比来判断是不是obj的父元素
          if(obj==this)  return true;  
           obj=obj.parentNode;
         }  
              return false;  
          };  
      }   function test(obj, e) {
    if (e.currentTarget) {
       if (e.relatedTarget != obj) {
        if (obj != e.relatedTarget.parentNode && !obj.contains(e.relatedTarget)) {
         return true;
        }
       }
    } else {
       if (e.toElement != obj) {
        if (obj != e.toElement.parentNode && !obj.contains(e.toElement)) {
         return true;
        }
       }
    }
    }</script>
    </head>
    <body>
      <div>
      <img id="img_Person" style="cursor:pointer;" oncontextmenu="return false;" onmousedown="contextMenuOperation(event);" src="Images/girl.jpg" alt="原圖"/>
      </div>
      <div id="div_ContextMenu" style="border:1px solid green;width:150px;height:100px;display:none;" OnMouseOut="contextMenu(event);">
      <ul style="list-style: none; list-style-type:none;margin:0px;background-color:White;">
      <li><a id="isFrame2" href="#"><font algin="center">弹出</font></a></li>
      <li><a href="#"><font algin="center">搜狐</font></a></li>
      </ul>
      </div>
    </body>
    </HTML>楼主这个可以试试
      

  7.   

    以前写的,可以看一下http://blog.csdn.net/danica7773/article/details/5609867