scrollLeft Property

DHTML, HTML, & CSS

scrollLeft Property


Sets or retrieves the distance between the left edge of the object and the leftmost portion of the content currently visible in the window.

Syntax

HTMLN/A
Scriptingobject.scrollLeft [ = 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 propertiesInternet Link.

Remarks

The scrollLeft property's value is equal to the horizontal 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 0. 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 loads.

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 vertically, its scrollLeft 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 locationInternet Link.

Example

This example uses the scrollLeft 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.scrollLeft)>
<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:
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

scrollHeight, scrollTop, scrollWidth


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.