Click to return to the DHTML, HTML     
scrollLeft Property     scrollWidth Property     DHTML Properties    
Web Workshop  |  DHTML, HTML & CSS

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

HTMLN/A
Scriptingobject.scrollTop [ = iDistance ]

Possible Values

iDistanceInteger 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>

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
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

scrollHeight, scrollLeft, scrollWidth



Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.