DOM:element.getClientRects
From MDC
This article covers features introduced in Firefox 3
Contents |
[edit] Summary
Returns a collection of rectangles that indicate the bounding rectangles for each line of text in a client.
[edit] Syntax
var rectCollection = object.getClientRects();
[edit] Returns
The returned value is a collection of TextRectangle objects, one for each CSS border-box associated with the element. Each TextRectangle object contains read-only left, top, right and bottom properties describing the border-box, in pixels, with the top-left relative to the top-left of the document's CSS canvas, unless the element is inside an SVG foreignobject element, in which case the top-left is relative to the nearest foreignobject ancestor and in the coordinate system of that foreignobject.
The amount of scrolling that has been done of the viewport area is taken into account when computing the rectangles.
The returned rectangles do not include the bounds of any child elements that might happen to overflow.
For HTML AREA elements, SVG elements that do not render anything themselves, display:none elements, and generally any elements that are not directly rendered, an empty list is returned.
Rectangles are returned even for CSS boxes that have empty border-boxes. The left, top, right and bottom coordinates can still be meaningful.
Fractional pixel offsets are possible.
[edit] Example
var rects = obj.getClientRects(); var numLines = rects.length;
[edit] Specification
Not part of any W3C specification.
[edit] Notes
getClientRects() was first introduced in the MS IE DHTML object model.