asp.net.ph

Skip Navigation Links

offsetTop Property

DHTML Object Properties   DHTML Objects


Retrieves the calculated top position of the object relative to the layout or coordinate parent, as given by the offsetParent property.

Syntax


HTML N/A
Script [ iCoord = ] object.offsetTop

Possible Values


iCoord Integer representing the top position.

The property is read-only with no default value.

Remarks

Using a combination of offset* properties, you can determine the location, width, and height of an object by using the offsetLeft, offsetTop, offsetHeight, and offsetWidth properties. These numeric properties specify the physical coordinates and dimensions of the object relative to the object’s offset parent.

For more information on how to access the dimension and location of objects on the page through the document object model, see Measuring Element Dimension and Location.

Example

The following example demonstrates use of the offsetTop property to determine whether an object is in the user's view.

<script language="JavaScript">
function isinView ( oObject ) {
var oParent = oObject.offsetParent;
var iOffsetTop = oObject.offsetTop;
var iClientHeight = oParent.clientHeight;
if ( iOffsetHeight > iClientHeight ) {
  alert ( "Scroll down for the message." );
  }
}
</script>
...
<button onclick="isinView ( this )">
  Click here</button>
...
<div id=oDiv 
  STYLE="position:absolute; top:900; left:0;">
...
</div>

This feature requires Microsoft® Internet Explorer® 4.0 or later.

 Show me 

See Also

offsetParent, Measuring Element Dimension and Location



>

© 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