Name

offsetLeft, offsetTop — NN n/a IE 4 DOM n/a

Synopsis

Read-only

These properties should represent the left and top coordinates of the element’s content relative to the containing element, exclusive of padding, borders, or margins. You can determine the containing element via the offsetParent property. Unfortunately, Internet Explorer 4 implements these two properties very unevenly across operating systems. See Section 9.2 earlier in this chapter.

Example

if (document.all.elementID.offsetLeft <= 20 &&
document.all.elementID.offsetTop <=40) {
    ...
}

Value

Integer pixel count.

Default

None.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.