you are assigning a mouseClick
to document object
here:
document = mouseClick;
Should be:
document.onclick = mouseClick;
Domanda
I'm having problems trying to record the exact coordinates a click was made. The first readMouseMove function is working exactly how it is supposed to. Displaying the mouse coordinates when i scroll around. The second mouseClick function should record the coordinates only when a click is made. At the moment it's the same as the function above but it seems I can only use the clientx/y event once. Would there be a way to record the mouse click without having it be relative to an object somewhere?
<script type='text/javascript'>
function readMouseMove(e) {
var xandy = 'x=' + e.clientX + " " +'y=' + e.clientY;
document.getElementById('divOne').innerHTML = xandy;
};
function mouseClick(e) {
var clickers = 'x=' + e.clientX + " " +'y=' + e.clientY;
document.getElementById('divTwo').innerHTML = clickers;
};
function clearAll() {
document.getElementById('divTwo').innerHTML = " "
};
document.onmousemove = readMouseMove;
document = mouseClick;
</script>
Soluzione
you are assigning a mouseClick
to document object
here:
document = mouseClick;
Should be:
document.onclick = mouseClick;