Get the clicked position when the mouse is clicked, and pay the javascript source code. If it is the current position of the mouse, you only need to change onmousedown to onmousemove to move the mouse.
Javascript Code copies content to clipboard
function mousePosition(ev){
if(ev.pageX || ev.pageY){
return {x:ev.pageX, y:ev.pageY};
}
return {
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y:ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
function mouseMove(ev){
ev = ev || window.event;
var mousePos = mousePosition(ev);
document.getElementById('div1').value = mousePos.x;
document.getElementById('div2').value = mousePos.y;
}
document.onmousedown = mouseMove;
Add in html
xml/HTML Code copy content to clipboard
The x-axis coordinate is:<input id="div1" />The y-axis coordinate is:<input id="div2" />
Then you click your mouse to display its position coordinates.