Click to return to the DHTML, HTML     
doReadRequest Method     duplicate Method     DHTML Methods    
Web Workshop  |  DHTML, HTML & CSS

doScroll Method


Simulates a click on a scroll-bar component.

Syntax

object.doScroll([sScrollAction])

Parameters

sScrollActionOptional. String that specifies how the object scrolls, using one of the following values:
scrollbarDownDefault. Down scroll arrow is at the specified location.
scrollbarHThumbHorizontal scroll thumb or box is at the specified location.
scrollbarLeftLeft scroll arrow is at the specified location.
scrollbarPageDownPage-down scroll bar shaft is at the specified location.
scrollbarPageLeftPage-left scroll bar shaft is at the specified location.
scrollbarPageRightPage-right scroll bar shaft is at the specified location.
scrollbarPageUpPage-up scroll bar shaft is at the specified location.
scrollbarRightRight scroll arrow is at the specified location.
scrollbarUpUp scroll arrow is at the specified location.
scrollbarVThumbVertical scroll thumb or box is at the specified location.
downComposite reference to scrollbarDown.
leftComposite reference to scrollbarLeft.
pageDownComposite reference to scrollbarPageDown.
pageLeftComposite reference to scrollbarPageLeft.
pageRightComposite reference to scrollbarPageRight.
pageUpComposite reference to scrollbarPageUp.
rightComposite reference to scrollbarRight.
upComposite reference to scrollbarUp.

Return Value

No return value.

Remarks

Cascading style sheets (CSS) allow you to scroll on all objects through the overflow property.

When the content of an element changes and causes scroll bars to display, the doScroll method might not work correctly immediately following the content update. When this happens, you can use the setTimeout method to enable the browser to recognize the dynamic changes that affect scrolling.

Example

This example uses the doScroll method to scroll through a text area when the user clicks a button.

Sample Code

<HEAD>
<SCRIPT>  
function scrollBehavior()
{
document.body.doScroll("scrollbarPageRight");
}

function scrollBehavior1()
{
txtScrollMe.doScroll("scrollbarDown");
}

function scrollBehavior2()
{
txtScrollMe.doScroll("scrollbarPageDown");
}
</SCRIPT>
</HEAD>
<BODY>
<BUTTON
   onclick="scrollBehavior()"
   CLASS="colorIt"
>
Click to Scroll Page
</BUTTON>
<BR>
<HR>
<BUTTON
   onclick="scrollBehavior1()"
   ondblclick="scrollBehavior2()"
   CLASS="colorIt">
   Click to Scroll Text Area
</BUTTON><BR><BR>
<TEXTAREA ID=txtScrollMe CLASS="colorIt">
    This text area
    will scroll downward when the
    "Click to Scroll the Text Area"
    button is clicked. The doScroll method 
    will scroll it as if the down arrow
    component of the scroll bar had 
    been clicked. Double-click the
    button to scroll down a whole page.
</BODY>

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

This example uses the doScroll method to scroll down a text area in one-second intervals.

<HEAD>
<SCRIPT>
var iTimer;
function timeIt()
{
iTimer = setInterval("scrollIt()", 1000);
}
function scrollIt()
{
oScrollMe.doScroll("down");
}
</SCRIPT>
</HEAD>
<BODY onload="timeIt()">
<DIV ID=oScrollMe STYLE="width:200px;height:75px;overflow:scroll">

</DIV>
</BODY>

This feature requires Internet Explorer 5 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:
BODY, custom, DIV, SPAN, TEXTAREA

See Also

componentFromPoint, onScroll



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.