asp.net.ph

Skip Navigation Links

offsetParent Property

DHTML Object Properties   DHTML Objects


Returns a reference to the container object that defines the top and left offsets for the object.

Syntax


HTML N/A
Script [ oElement = ] object.offsetParent

Possible Values


oElement Container object.

The property is read-only with no default value.

Remarks

The offsetLeft and offsetTop property values are relative to the object specified by the offsetParent property for the object. Most of the time the property returns BODY.

Example

In the following document, even though the TD object appears to the far right in the document, its position is ( 0,0 ) because its offset parent is TR, not the document body.

<html>
<head>
<title>Elements: Positions</title>
</head>
<script language="JScript">
function showPosition ( ) {
var el = document.all.oCell;
alert ( "The TD element is at ( " + 
 el.offsetLeft + "," + el.offsetTop + " ) \n" +
 "The offset parent is " + el.offsetParent.tagName );
}
</script>
<body onload="showPosition ( )">
<p>This document contains a right-aligned table.
<table BORDER=1 ALIGN=right>
<tr><td id=oCell>This is a small table.
</table>
</body>
</html>
See Also

Measuring Element Dimension and Location, The Browser Screen



>

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note