This topic has not yet been rated - Rate this topic

top property

Sets or retrieves the top coordinate of the rectangle surrounding the object content.

Syntax

JavaScript

p = object.top

Property values

Type: Integer

the top coordinate of the rectangle, in pixels.

Remarks

Use this 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.

To access the top coordinate of the bounding rectangle of an object, use this syntax:


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

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 = \nUpper left coordinates: "
        + oBndRct.left + " " + oBndRct.top +
        "\nLower right coordinates: "
        + oBndRct.right + " " + oBndRct.bottom);
}
</SCRIPT>
</HEAD>	
<BODY>
<P ID=oPara onclick="getCoords(this)">

See also

TextRectangle Constructor
Reference
bottom
left
right
TextRectangle

 

 

Send comments about this topic to Microsoft

Build date: 2/14/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ