マウスのxy値を取得します

438 ワード

//         
function getPosition(ev){   
    ev = ev || window.event;   
    var point = {x:0,y:0};   
    if(ev.pageX || ev.pageY){   
        point.x = ev.pageX;   
        point.y = ev.pageY;   
    } else {//  ie   
        point.x = ev.clientX + document.body.scrollLeft - document.body.clientLeft;   
        point.y = ev.clientY + document.documentElement.scrollTop;   
    }   
    return point;   
    }