Get mouse screen X and Y : Mouse Event « Event « JavaScript Tutorial






<html>
<head>
<title>Mouse Events Example</title>
<script type="text/javascript">
    function handleEvent(oEvent) {
        var oTextbox = document.getElementById("txt1");
        oTextbox.value += "\n    at (" + oEvent.screenX + "," + oEvent.screenY + ") on the screen";
    }
</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>








15.8.Mouse Event
15.8.1.Get mouse clicked button
15.8.2.Is Shift key pressed during the mouse click
15.8.3.Is alt key pressed during the mouse click
15.8.4.Is control key pressed during the mouse click
15.8.5.Mouse event target element name
15.8.6.Mouse event from and to elements (IE)
15.8.7.Mouse event related element (Firefox)
15.8.8.onmouseover event handler
15.8.9.onmouseout event handler
15.8.10.onmousedown event handler
15.8.11.onmouseup event handler
15.8.12.onclick mouse event handler
15.8.13.ondblclick mouse event handler
15.8.14.Display current mouse position in status bar (IE)
15.8.15.Use mouse in/out action to trigger the style change
15.8.16.Get mouse client X and Y
15.8.17.Get mouse screen X and Y
15.8.18.Set element's pixelTop and pixelLeft to current mouse event (IE)
15.8.19.Get X/Y screen position (IE)