<html>
<body>
<form>
<div id="divX" > X</div>
<div id="divY" > Y</div>
</form>
<script language="JavaScript">
<!--
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getXY;
var tmpX = 0
var tmpY = 0
function getXY(e) {
if (IE) {
tmpX = event.clientX + document.body.scrollLeft
tmpY = event.clientY + document.body.scrollTop
} else {
tmpX = e.pageX
tmpY = e.pageY
}
if (tmpX < 0){tmpX = 0}
if (tmpY < 0){tmpY = 0}
document.getElementById('divX').innerHTML = tmpX;
document.getElementById('divY').innerHTML = tmpY;
return true
}
//-->
</script>
</body>
</html>
No comments:
Post a Comment