<p>Click in the div element below to get the x (horizontal) and y (vertical) coordinates of the mouse pointer, when it is clicked.</p><div onclick="showCoords(event)"><p id="demo"></p></div><p><strong>Tip:</strong>Try to click different places in the div.</p><script>functionshowCoords(event) {
var cX = event.clientX;
var sX = event.screenX;
var cY = event.clientY;
var sY = event.screenY;
var coords1 ="client - X: "+ cX +", Y coords: "+ cY;
var coords2 ="screen - X: "+ sX +", Y coords: "+ sY;
document.getElementById("demo").innerHTML = coords1 +"<br>"+ coords2;
}
</script>
Posted by: Guest
on April-14-2020
0
access mouse position javascript
(function() {
document.onmousemove = handleMouseMove;
functionhandleMouseMove(event) {
var eventDoc, doc, body;
event = event || window.event; // IE-ism// If pageX/Y aren't available and clientX/Y are,// calculate pageX/Y - logic taken from jQuery.// (This is to support old IE)if (event.pageX ==null&& event.clientX !=null) {
eventDoc = (event.target && event.target.ownerDocument) || document;
doc = eventDoc.documentElement;
body = eventDoc.body;
event.pageX = event.clientX +
(doc && doc.scrollLeft || body && body.scrollLeft ||0) -
(doc && doc.clientLeft || body && body.clientLeft ||0);
event.pageY = event.clientY +
(doc && doc.scrollTop || body && body.scrollTop ||0) -
(doc && doc.clientTop || body && body.clientTop ||0 );
}
// Use event.pageX / event.pageY here
}
})();
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems
resetting your password contact us
Check Your Email and Click on the link sent to your email