Language References
Sets or retrieves the top position of the object in the units specified by the CSS top attribute.
HTML |
N/A |
Script |
object.style.posTop [ = fTop ] |
fTop |
Any valid floating-point number. |
The property is read/write with no default value.
This property reflects the value of the CSS top attribute for positioned items. This property always returns zero for nonpositioned items because "top" is not meaningful unless the object is positioned. Use the offsetTop property to calculate actual positions within the document area.
Setting this property changes the value of the top position but leaves the units designator for the property unchanged.
Unlike the top property, this property's value is a floating-point number, not a string.
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.
The following JScript® ( compatible with ECMA-262 language specification ) example moves the first IMG object up by 10 units.
document.all.tags ( "IMG" ).item ( 0 ).style.posTop -= 10;
In the following sample, the posTop is incremented through use of a timer.
<script language="JavaScript">
function moveThis ( ) {
:
if ( sphere.style.posLeft<900 ) {
sphere.style.posTop += 2;
sphere.style.posLeft += 2;
window.setTimeout ( "moveThis ( );", 1 );
}
}
...
</script>
This feature requires Microsoft® Internet Explorer® 4.0 or later.
Show me
pixelTop