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开发者_JS百科, 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.
The accepted tutorial only link answer points to a broken link. For people coming by searching here
Check out the jquery mousemove api.
You can use the above as
$("#SomeTag").mousemove(function(event) {
  var msg = "Handler for .mousemove() called at ";
  msg += event.pageX + ", " + event.pageY;
  $("#SomeDisplayTag").append("<div>" + msg + "</div>");
});
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论