关于onmouseover和onmouseout重复执行的修正方法

//onmouseover onmouseout bug
function contains(parentNode, childNode) {
    if (parentNode.contains) {
         return parentNode != childNode && parentNode.contains(childNode);
    } else {
        return !!(parentNode.compareDocumentPosition(childNode) & 16);
    }
}

function checkHover(e,target){
    
    if (getEvent(e).type=="mouseover") {
       return !contains(target,getEvent(e).relatedTarget||getEvent(e).fromElement) && !((getEvent(e).relatedTarget||getEvent(e).fromElement)===target);
    } else {
       return !contains(target,getEvent(e).relatedTarget||getEvent(e).toElement) && !((getEvent(e).relatedTarget||getEvent(e).toElement)===target);
    }
}

function getEvent(e){
    
    return e || window.event;
}
posted @ 2012-11-21 09:31  平阳小安  阅读(368)  评论(0编辑  收藏  举报