How do I get cursor X and Y in javascript?
var $curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var $curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
I had found this two, but they appear as "undefined". Any ideas?
Thanks!
I assume you don't want a framework answer. If not, try this:
document.onclick=function(evt) {
evt = (evt || event);
alert(evt.clientX + ' ' + evt.clientY);
}
I wasn't sure what event you wanted, so I just used an onclick
event.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With