1
//判断鼠标点击的位置是否在某个div区域内,可用在右键菜单的显示与隐藏等
function isInDiv(event,divId){
    var div = document.getElementById(divId)
    var x=event.clientX
    var y=event.clientY
    var divx1 = div.offsetLeft
    var divy1 = div.offsetTop
    var divx2 = div.offsetLeft + div.offsetWidth
    var divy2 = div.offsetTop + div.offsetHeight
    return ( x < divx1 || x > divx2 || y < divy1 || y > divy2)
}

余大鱼
41 声望1 粉丝

雷猴呀!