This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

left

Summary

Returns the left value for a ClienRect object.

Property of css/cssom/ClientRectcss/cssom/ClientRect

Syntax

Note: This property is read-only.

var pixelsFromLeft = clientRect.left;

Return Value

Returns an object of type NumberNumber

The number of pixels.

Examples

This example uses the getBoundingClientRect method to retrieve the coordinates of the bounds of the text rectangles within the element.

<SCRIPT>
function getCoords(oObject) {
    oBndRct=oObject.getBoundingClientRect();
    alert("Bounding rectangle = \nUpperleft coordinates: "
        + oBndRct.left + " " + oBndRct.top +
        "\nLowerright coordinates: "
        + oBndRct.right + " " + oBndRct.bottom);
}
</SCRIPT>
</HEAD>
<BODY>
<P ID=oPara onclick="getCoords(this)">

View live example

Notes

To access the left coordinate of the second text rectangle of a TextRange object, use this syntax:

oRct = oTextRange.getClientRects();
oRct[1].left;

Note that because the collection index starts at 0, the second item index is 1. To access the left coordinate of the bounding rectangle of an element object, use this syntax:

oBndRct = oElement.getBoundingClientRect();
oBndRct.left;

Attributions