Magazine |
| | Community |
| | Workshop |
| | Tools & Samples |
| | Training |
| | Site Info |
|
|
||||||||
|
Sets or retrieves the distance between the top of the object and the topmost portion of the content that is currently visible in the window.
Syntax
HTML N/A Scripting object.scrollTop [ = iDistance ]
Possible Values
iDistance Integer value representing the distance, in pixels. The property is read/write with a default value of 0.
Remarks
The property's value is equal to the vertical distance that the content of the object has been scrolled. Although the value can be set to any positive or negative value, if the assigned value is less than zero, the property is set to zero. If the assigned value is greater than the maximum possible, the property is set to the maximum possible.
This property can be set inline but the results may not be consistent while the page is loading.
This property is always zero for objects that do not have scroll bars. For these objects, setting the property has no effect.
When a MARQUEE object is scrolling horizontally its scrollTop property is set to zero, overriding any script setting.
For more information on how to access the dimension and location of elements on the page through the document object model, see Measuring Element Dimension and Location.
Example
The following example shows how the scrollTop property can be used to determine the amount of scrolling done by an object.
Sample Code
<DIV ID=oDiv STYLE="position:absolute; width:200px; height:100px; overflow:scroll" onclick=alert(this.scrollTop)> <SPAN STYLE="width:250px"> . . . </SPAN></DIV>
Applies To
A, ADDRESS, APPLET1, B, BDO, BIG, BLOCKQUOTE, BODY1, BUTTON1, CAPTION1, CENTER, CITE, CODE, COL, COLGROUP, DD, DFN, DIR, DIV1, DL, DT, EM, EMBED1, FIELDSET1, FORM, HEAD, Hn, HTML, HTMLAREA, I, IMG1, INPUT type=button1, INPUT type=checkbox1, INPUT type=file1, INPUT type=hidden1, INPUT type=image1, INPUT type=password1, INPUT type=radio1, INPUT type=reset1, INPUT type=submit1, INPUT type=text1, ISINDEX, KBD, LABEL, LEGEND1, LI, LISTING, MARQUEE1, MENU, META, NOBR, OBJECT1, OL, OPTION, P, PLAINTEXT, PRE, S, SAMP, SCRIPT, SELECT, SMALL, SPAN1, STRIKE, STRONG, STYLE, SUB, SUP, TABLE1, TBODY, TD1, TEXTAREA1, TFOOT, TH, THEAD, TR1, TT, U, UL, VAR, XMP1Available as of Internet Explorer 4.0 or later. Otherwise, available as of Internet Explorer 5 or later.
See Also
Does this content meet your programming needs? Write us!
© 1998 Microsoft Corporation. All rights reserved. Terms of use.