Getting the position and size of the element in the viewport

By | 2012/11/17
var rect = object.getBoundingClientRect();

Returns

rect.top
rect.left
rect.right //Relative to left
rect.bottom //Relative to right
 
rect.width
rect.height

Bug in IE < 8
IEs adds 2px to each property (left, top, right, bottom) which have to be substracted manually.

Suppored in all browsers.