Javascript onmousemove get relative coordinates
3 answers
var guide = null; function aim(event) { if(window.event) event = window.event; //grrr IE var mousex = event.clientX - guide.offsetLeft; alert('mouse x' + mousex) } function init() { guide = document.getElementById("guide") guide.onmousemove = aim; } <body onload="init();"> This is similar to working with both browsers. I can not do onmousemove = "aim ()"; in html because it does not skip the mousemove event object.
+9
user181351
source share