/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
if(window.addEventListener) { element.addEventListener('mousemove', handleMouseClick, false); } else { element.attachEvent('onmousemove', handleMouseClick); } function handleMouseClick(e) { if(window.event) e = window.event; // mouse position relative to the top of the document var xpos = e.pageX - this.offsetLeft; var ypos = e.pageY - this.offsetTop; // mouse position relative to the viewport //var xpos = e.clientX - this.offsetLeft; //var ypos = e.clientY - this.offsetTop; }
Comments
