<html>
<head>
<style>
div{
border: 1px solid black;
width: 500px;
height: 500px;
}
</style>
<script>
window.onload = function(){
document.body.onmousedown = function(event){
var mouseStartX = event.clientX;
var mouseStartY = event.clientY;
document.body.onmousemove = function(event){
var div = document.getElementsByTagName("div");
div[0].innerHTML = event.clientX + " " + event.clientY;
}
};
};
</script>
</head>
<body>
<div>
</div>
</body>
</html>
I have written code to show the mouse cursor position only when both onmousedown and onmousemove events are triggered simultaneously by clicking and dragging the mouse.