Abel Tamayo wrote: > Ok, this is a noob question, but what is the fastest, cross-browser > way to obtain the mouse coordenates? I've found tons of info about > this in google, but it all seemed a little bit dated (with comments > about Netscape 4 and the war of browsers all the time). > Thanks. > ------------------------------------------------------------------------ > > _______________________________________________ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > Abel,
It depends on what mouse coorldinates you're looking for -- coordinates on page or coordinates in viewport. See; http://www.quirksmode.org/dom/w3c_events.html#mousepos What is *VERY* cool about jquery is that it "fixes" the event data! This means you don't need to code a nasty platform detection/workaround, and can just use event.pageX & event.pageY for instance. E.g. to continually output the coords on page, you can do; <script type="text/javascript"> $().mousemove(function(e){ $('body').append('X-CORD: '+ e.pageX +' Y-CORD:'+ e.pageY +'<br />'); }); </script> ~ BRice _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/