Javascript Reference
Categories: TextRectangle

javascript TextRectangle Description

@March 15, 2008, 1:22 a.m.
TextRectangleFirefox/Netscape/NN n/a IE 5(Win) Chrome/Safari/DOM n/a  


A TextRectangle object contains the coordinates of the four edges of an invisible box that surrounds a string of body text. Two methods of all element objects and the TextRange object produce information about two different kinds of text rectangles. The getClientRects( ) method returns a collection of line-by-line text rectangles; the getBoundingClientRect( ) method returns a single TextRectangle object that has coordinates that encompass all line-by-line rectangles.


Invoking either of these methods gets the rectangles' values instantaneously. Resizing the window or altering the content of the target object may change the actual rectangles, but the TextRangle objects obtained earlier do not keep pace with the changes (since the content of each line's rectangle is likely to change). Therefore, obtain TextRectangle values immediately before you need to process them in other script statements.

Object Model Reference
elementOrTextRangeReference.getBoundingClientRect( )
elementOrTextRangeReference.getClientRects( )[i]
Object-Specific Properties
Object-Specific Methods


Object-Specific Event Handler Properties


Powered by Linode.