clientX property

Sets or retrieves the x-coordinate of the mouse pointer, or user's finger, position relative to the client area of the window, excluding window decorations and scroll bars. For the standards based property, see clientX.

Syntax

JavaScript

p = object.clientX

Property values

Type: Integer

the x-coordinate, in pixels.

Remarks

Because the clientX property returns a value relative to the client, you can add the value of the scrollLeft property to determine the distance of the x-coordinate from the edge of the body element.

Within a viewlink, the client area begins at the edge of the master element.

Examples

This example uses the clientX property to determine the mouse position relative to the window. The status window shows the mouse position at all times.


<script>
function clientCoords()
{
    var offsetInfo = ""
    clientInfo = "The x coordinate is: " + window.event.clientX + "\r"
    clientInfo += "The y coordinate is: " + window.event.clientY + "\r"
    console.log(clientInfo);
}
</script>
</head>

<body onmousemove="window.status = 'X=' + window.event.clientX +
    ' Y=' + window.event.clientY" ondblclick="clientCoords()">

See also

event

 

 

Send comments about this topic to Microsoft

Build date: 11/14/2012

Show:
© 2015 Microsoft