Javascript Reference
Categories: Element

javascript Element offsetLeft, offsetTop

@March 15, 2008, 1:22 a.m.
offsetLeft, offsetTop NN 6 IE 4 DOM n/a  

Read-only  

Broadly speaking, provide the left and top coordinates of the element's box, but with minor variations with respect to the coordinate system context (vis--vis the offsetParent element) influenced by various operating system versions of IE and compatibility modes controlled by the DOCTYPE declaration. Implemented in Netscape 6 as a convenience, even though not part of the W3C DOM. For positioned elements, you should rely more on the element's style properties that control location in the document or browser viewing space.

 
Example
 
if (document.getElementById("elementID").offsetLeft <= 20 &&
document.getElementById("elementID").offsetTop <=40) {
    ...
}
 
Value

Integer pixel count.

 
Default

Element-specific.


Powered by Linode.