Program to show Mouse Position using JavaScript.
<!DOCTYPE html>
<html>
<head>
<script 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)
{
tempX = event.clientX + document.body.scrollLeft
tempY = event.clientY + document.body.scrollTop
}
else
{
tempX = e.pageX
tempY = e.pageY
}
document.Show.MouseX.value = tempX
document.Show.MouseY.value = tempY
return true
}
</script>
</head>
<body>
<form name="Show">
<input type="text" name="MouseX" value="0" size="4"> X<br>
<input type="text" name="MouseY" value="0" size="4"> Y<br>
</form>
</body>
</html>
0 comments :