div bug

来源:互联网 发布:机器人编程语言 编辑:程序博客网 时间:2024/06/05 19:35

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 fun(e,o) {
        /* FF 下判断鼠标是否离开DIV */
        if(window.navigator.userAgent.indexOf("Firefox")>=1) {
        if(o.contains(e.relatedTarget)==false)
        {
         o.style.display="none";
        }
        }

        /* IE */
        if(o.contains(event.toElement ) == false){}
       
    }

</script>

原创粉丝点击