get mouse position





6
Date Submitted Fri. Jul. 20th, 2007 11:42 PM
Revision 1 of 1
Helper lavaramano
Tags DOM | JavaScript | mouse | onclick | pointer
Comments 1 comments
it give us the position of the mouse. works on IE and Firefox

use:
onclick="posicion_mouse(event)"

function posicion_mouse(e) {
        var posx = 0;
        var posy = 0;
        if(!e){ var e = window.event }
 
        posx = (e.pageX) ? e.pageX : window.event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
        posy = (e.pageY) ? e.pageY : window.event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
 
        return {y: posy, x:posx}
}
 

mauro l

lusers.com.ar/
______________________
// a sphincter says what?

Comments

Comments Spelling
Mon. Jun. 16th, 2008 2:27 PM    Scripter sehrgut

Voting