clientX Property

DHTML, HTML, & CSS

clientX Property


Retrieves the x-coordinate of the mouse pointer's position relative to the client area of the window, excluding window decorations and scroll bars.

Syntax

HTMLN/A
Scripting[ iXPos = ] event.clientX

Possible Values

iXPosInteger that specifies the x-coordinate, in pixels.

The property is read-only with no default value.

Remarks

Since the clientX property returns a value relative to the client, you can add the value of the scrollLeft property to determine the distance from the edge of the BODY element.

Example

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.

Sample Code

<SCRIPT>
function clientCoords()
{
    var offsetInfo = ""
    clientInfo = "The x coordinate is: " + window.event.clientX + "\r"
    clientInfo += "The y coordinate is: " + window.event.clientY + "\r"
    alert(clientInfo);
}
</SCRIPT>
</HEAD>
<BODY onmousemove="window.status = 'X=' + window.event.clientX +
    ' Y=' + window.event.clientY"
    ondblclick="clientCoords()">

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
Version data is listed when the mouse hovers over a link, or the link has focus.
event

Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.