Click to See Complete Forum and Search --> : Mouse tracking


greenpizza13
11-20-2003, 11:04 AM
I need a sinmple mouse trackign script to show me how to track the mouse in internet explorer or netscape. Thx in advance!

fredmv
11-20-2003, 11:07 AM
Can you please be more desriptive as to what you're trying to do? Do you mean "tracking the mouse", as in, reporting the current X and Y positions of the cursor?

greenpizza13
11-20-2003, 11:08 AM
I think If i knew how to detect the mouses x and y coords I could handle the rest... like having a div follow it/

96turnerri
11-20-2003, 07:08 PM
<body>

<form name="Show">
X <input type="text" name="MouseX" value="0" size="4"><br>
Y <input type="text" name="MouseY" value="0" size="4"><br>
</form>

<script language="JavaScript1.2" type="text/javascript">
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0;
var tempY = 0;
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
}
else { // grab the x-y pos.s if browser is NS
tempX = e.pageX;
tempY = e.pageY;
}
if (tempX < 0){tempX = 0;}
if (tempY < 0){tempY = 0;}
document.Show.MouseX.value = tempX;
document.Show.MouseY.value = tempY;
return true;
}
</script>
</body>

yphasukyued
11-21-2003, 03:26 PM
How to tracking X,Y of mouse move on the IMAGE?

96turnerri
11-21-2003, 05:24 PM
sorry i dont understand what you mean, can you xplain yourself?

yphasukyued
11-24-2003, 07:15 AM
Thanks for your replied, I just found the answer.