Sets or retrieves the distance between the top of the object and the topmost portion of the content currently visible in the window. dhtml语法 HTML | N/A |
---|
Scripting | object.scrollTop [ = iDistance ] |
---|
DHTML可能的值 iDistance | Integer that
specifies or receives the distance, in pixels. |
The property is read/write.
The property has 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 about dynamic properties.
remarks this property's value equals the current vertical offset of the content within the scrollable range. although you can set this property to any value, if you assign a value less than 0, the property is set to 0. if you assign a value greater than the maximum value, the property is set to the maximum value. 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 dynamic html(动态html,即dhtml) object model, see measuring element dimension and location.
DHTML代码范例
This example uses the scrollTop property to determine the amount scrolled by the object. <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 Microsoft® Internet Explorer 4.0 or later. Click the following icon to install the latest version. Then reload this page to view the sample.
是否符合公共标准
There is no public standard that applies to this property.
Applies To |
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 | |
更多语法参考 scrollheight, scrollleft, scrollWidth
|