asp.net.ph

Skip Navigation Links

top Property

TextRectangle Properties   DHTML Object Properties


Retrieves the top coordinate of the rectangle surrounding the object content.

Syntax


HTML N/A
Script [ iCoord = ] oTextRectangle.top

Possible Values


iCoord Integer value representing the top coordinate of the rectangle, in pixels.

The property is read-only with no default value.

Remarks

Use the following syntax to access the top coordinate of the second text rectangle of a TextRange object:

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

Note that the collection index starts at 0, so the second item index is 1.

Use the following syntax to access the top coordinate of the bounding rectangle of an object:

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

Example

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 )">

This feature requires Microsoft® Internet Explorer® 5.0 or later.

 Show me 

Applies To

TextRectangle

See Also

TextRectangle Collection, TextRectangle Object, bottom, left, right



>

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note