js 获取鼠标位置

function mousepositon(event) {
    event = event || window.event 
    if(event.pageX || event.pageY){ 
         return {x:event.pageX, y:event.pageY}; 
    } 
    return { 
        x:event.clientX + document.body.scrollLeft - document.body.clientLeft, 
        y:event.clientY + document.body.scrollTop - document.body.clientTop 
    }; 
}  

你可能感兴趣的:(js)