Get mouse Y position in JavaScript

Description

The following code shows how to get mouse position.

Example


<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
  function clicked() {<!--   ww w  .  j  ava 2  s  .c  o m-->
    document.writeln("You clicked at the coordinates: X = " + event.x
        + " Y = " + event.y);
  }
</script>
</head>
<body onmousedown="clicked()">

</body>
</html>

Click to view the demo





















Home »
  Javascript »
    Javascript Reference »




Array
Canvas Context
CSSStyleDeclaration
CSSStyleSheet
Date
Document
Event
Global
History
HTMLElement
Input Element
Location
Math
Number
String
Window