Javascript Reference
Categories: DIV

javascript DIV scrollLeft, scrollTop

@May 12, 2009, 7:46 a.m.
scrollLeft, scrollTop Firefox/Netscape/NN 7 IE 4 Chrome/Safari/DOM n/a  

 

Read/Write  

Provide the distance in pixels between the actual left or top edge of the DIV element's physical content and the left or top edge of the visible portion of the content. Setting these properties allows you to use a script to adjust the scrolling of content within a scrollable container, such as text in a textarea element or an entire document in the browser window or frame. When the content is not scrolled, both values are zero. Setting the scrollTop property to 15 scrolls the document upward by 15 pixels in the window; the scrollLeft property is unaffected unless explicitly changed. The property values change as the user adjusts the scrollbars. This is important for some event-driven positioning tasks in IE for Windows because the coordinate system for event offset measurements are with respect to the visible area of a page in the browser window. You must add document.body scrolling factors to align event coordinates with body content positions. Starting with IE 5 for Windows, the scrollLeft and scrollTop properties are available for all HTML element objects, but values for unscrollable elements are zero.

 
Example
 
document.body.scrollTop = 40;
 
Value

Positive integer or zero.

 
Default

0

my saver
Simptome Sarcina - 2011-11-18
thanks dude!
jhoan - 2011-05-15
nice explanation.
shwe - 2010-07-14

Powered by Linode.