scrollTop Property
Sets or retrieves the distance between the top of the object and the topmost portion of the content currently visible in the window.
Syntax
HTML N/A Scripting object.scrollTop [ = iDistance ]
Possible Values
iDistance Integer that specifies the distance, in pixels. The property is read/write with a default value of 0.
Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see dynamic properties.
Remarks
The property's value is equal to the vertical distance scrolled by the content of the object. Although the value can be set to any positive or negative value, if the assigned value is less than 0, the property is set to o. If the assigned value is greater than the maximum possible, the property is set to the maximum possible.
You can set this property inline, but the results might be inconsistent while the page is loading.
This property is always 0 for objects that do not have scroll bars. For these objects, setting the property has no effect.
When a MARQUEE object scrolls horizontally, its scrollTop property is set to 0, overriding any script setting.
For more information about how to access the dimension and location of elements on the page through the document object model, see measuring element dimension and location.
Example
This example uses the scrollTop property to determine the amount scrolled by the 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
[ Object Name ] Platform Version Win16: Win32: Mac: Unix: WinCE: Version data is listed when the mouse hovers over a link, or the link has focus. A, ADDRESS, APPLET, B, BDO, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, custom, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FORM, HEAD, Hn, HTML, I, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, ISINDEX, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, META, NOBR, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP
See Also
Did you find this topic useful? Suggestions for other topics? write us!
© 1999 microsoft corporation. all rights reserved. terms of use.