Partilhar via


Sys.UI.DomEvent clientX Field

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

var clientX = domEventVar.clientX;

Return Value

An integer that represents the x-coordinate in pixels.

Remarks

Use the clientX field to gets the horizontal offset of the mouse pointer's position relative to the client area of the browser window. The client area excludes window scroll bars.

Example

The following example shows how to use the clientX field to retrieve the x-coordinate of the mouse pointer's position relative to the client area of the browser window.

<script type="text/javascript">
    Sys.UI.DomEvent.addHandler($get("Button1"), "click", processEventInfo);

    function processEventInfo(eventElement) {
        var result = '';
        try {
            result += "altKey = " + eventElement.altKey + "<br/>";
            result += "button = " + eventElement.button + "<br/>";
            result += "keyCode = " + eventElement.keyCode + "<br/>";
            result += "clientX = " + eventElement.clientX + "<br/>";
            result += "clientY = " + eventElement.clientY + "<br/>";
            result += "ctrlKey = " + eventElement.ctrlKey + "<br/>";
            result += "offsetX = " + eventElement.offsetX + "<br/>";
            result += "offsetY = " + eventElement.offsetY + "<br/>";
            result += "screenX = " + eventElement.screenX + "<br/>";
            result += "screenY = " + eventElement.screenY + "<br/>";
            result += "shiftKey = " + eventElement.shiftKey + "<br/>";
            result += "target.id = " + eventElement.target.id + "<br/>";
            result += "type = " + eventElement.type + "<br/>";
        }
        catch(e) {
            alert("Error:" + e.message);
        }
        $get('Label2').innerHTML = result;
    }
 </script>
<script type="text/javascript">
    Sys.UI.DomEvent.addHandler($get("Button1"), "click", processEventInfo);

    function processEventInfo(eventElement) {
        var result = '';
        try {
            result += "altKey = " + eventElement.altKey + "<br/>";
            result += "button = " + eventElement.button + "<br/>";
            result += "keyCode = " + eventElement.keyCode + "<br/>";
            result += "clientX = " + eventElement.clientX + "<br/>";
            result += "clientY = " + eventElement.clientY + "<br/>";
            result += "ctrlKey = " + eventElement.ctrlKey + "<br/>";
            result += "offsetX = " + eventElement.offsetX + "<br/>";
            result += "offsetY = " + eventElement.offsetY + "<br/>";
            result += "screenX = " + eventElement.screenX + "<br/>";
            result += "screenY = " + eventElement.screenY + "<br/>";
            result += "shiftKey = " + eventElement.shiftKey + "<br/>";
            result += "target.id = " + eventElement.target.id + "<br/>";
            result += "type = " + eventElement.type + "<br/>";
        }
        catch(e) {
            alert("Error:" + e.message);
        }
        $get('Label2').innerHTML = result;
    }
 </script>

See Also

Reference

Sys.UI.DomEvent clientY Field

Sys.UI.DomEvent Class

Other Resources

Language Reference