TextRectangle Properties DHTML Object Properties
Retrieves the left coordinate of the rectangle surrounding the object content.
HTML |
N/A |
Script |
[ iCoord = ] oTextRectangle.left |
iCoord |
Integer value representing the left coordinate of the rectangle, in pixels. |
The property is read-only with no default value.
Use the following syntax to access the left coordinate of the second text rectangle of a TextRange object:
oRct = oTextRange.getClientRects ( );
oRct [ 1 ] .left;
Note that the collection index starts at 0, so the second item index is 1.
Use the following syntax to access the left coordinate of the bounding rectangle of an element object:
oBndRct = oElement.getBoundingClientRect ( );
oBndRct.left;
The example below demonstrates the use of the getBoundingRect method to retrieve the coordinates of the bounds of the text rectangles within the element.
<script language="JavaScript">
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 )">
...
</body>
This feature requires Microsoft® Internet Explorer® 5.0 or later.
Show me
TextRectangle
TextRectangle Collection, TextRectangle Object, bottom, right, top