I have a function in javascript that moves one div depending on the mouse position. This function is set on a setInterval() function and executed every second. I need to cap
well, if you listen to mouse move for the document and save its location, then, whenever you want, e.g. every second in your case you have the latest registered mouse position.
this is a jquery example
$(document).ready(function()
{
$().mousemove(function(e)
{
window.mouseX = e.pageX;
window.mouseY = e.pageY;
});
});
and your mousemove function would be
function mousemov() {
document.getElementById("myDiv").style.left = window.mouseX;
}