Visit Mozilla.org

DOM:element.getBoundingClientRect

From MDC

This article covers features introduced in Firefox 3


« Gecko DOM Reference

Contents

[edit] Summary

Returns a text rectangle object that encloses a group of text rectangles.

[edit] Syntax

var rectObject = object.getBoundingClientRect();

[edit] Returns

The returned value is a TextRectangle object which is the union of the rectangles returned by getClientRects() for the element, i.e., the CSS border-boxes associated with the element.

Empty border-boxes are completely ignored. If all the element's border-boxes are empty, then a rectangle is returned with a width and height of zero and where the top and left are the top-left of the border-box for the first CSS box (in content order) for the element.

The amount of scrolling that has been done of the viewport area is taken into account when computing the bounding rectangle.

[edit] Example

var rect = obj.getBoundingClientRect();

[edit] Specification

Not part of any W3C specification.

[edit] Notes

getBoundingClientRect() was first introduced in the MS IE DHTML object model.

[edit] References