Get mouse client X in JavaScript
Description
The following code shows how to get mouse client X and Y.
Example
<html>
<head>
<script type="text/javascript">
function handleEvent(oEvent) {<!--from w ww.ja va2 s.co m-->
var oTextbox = document.getElementById("txt1");
oTextbox.value += "\n at (" + oEvent.clientX + "," + oEvent.clientY
+ ") in the client";
}
</script>
</head>
<body>
<P>Use your mouse to click and double click the red square.</p>
<div style="width: 100px; height: 100px; background-color: red"
onclick="handleEvent(event)" id="div1"></div>
<P>
<textarea id="txt1" rows="15" cols="50"></textarea>
</p>
</body>
</html>