Where is that mouse (got scrollbars?)

[Total: 0    Average: 0/5]

This example shows both the mouse position as well as the scrollbar positions.

Head Code:

<script type=text/javascript>
var isIE = document.all?true:false;
if (!isIE) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMousePosition;
function getMousePosition(e) {
  var _x;
  var _y;
  if (!isIE) {
    document.exf1.sv_x.value = window.pageXOffset;
    document.exf1.sv_y.value = window.pageYOffset;
    _x = e.pageX;
    _y = e.pageY;
  }
  if (isIE) {
    _x = event.clientX + (document.exf1.sv_x.value = document.body.scrollLeft);
    _y = event.clientY + (document.exf1.sv_y.value = document.body.scrollTop);
  }
  document.exf1.cp_x.value=_x;
  document.exf1.cp_y.value=_y;
  return true;
}

function printBR(_n)
{
  for(var i=0;i<_n;i++)
  {
    document.write("<BR>");
  }
}
</script>

Body Code:

<script>
printBR(20);
</script>
<form name=exf1>
<table border=1>
<tr><td colspan=3>Position Of Cursor</td></tr>
<tr><td>Cursor Position</td>
    <td>X <input type=text name=cp_x value="<unknown>"></td>
    <td>Y <input type=text name=cp_y value="<unknown>"></td>
</tr>
<tr><td>Scroll Values</td>
    <td>X <input type=text name=sv_x value="<unknown>"></td>
    <td>Y <input type=text name=sv_y value="<unknown>"></td>
</tr>
</table>
</form>

<script>
printBR(20);
</script>
BOTTOM OF PAGE

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *