Simulates a click on a scroll-bar component.
dhtml语法
object.doScroll( [sScrollAction])
Parameters
sScrollAction |
Optional.
Stringthat specifies how the object scrolls, using one of the following values: scrollbarDown | Default. Down scroll arrow is at the specified location. | scrollbarHThumb | Horizontal scroll thumb or box is at the specified location. | scrollbarLeft | Left scroll arrow is at the specified location. | scrollbarPageDown | Page-down scroll bar shaft is at the specified location. | scrollbarPageLeft | Page-left scroll bar shaft is at the specified location. | scrollbarPageRight | Page-right scroll bar shaft is at the specified location. | scrollbarPageUp | Page-up scroll bar shaft is at the specified location. | scrollbarRight | Right scroll arrow is at the specified location. | scrollbarUp | Up scroll arrow is at the specified location. | scrollbarVThumb | Vertical scroll thumb or box is at the specified location. | down | Composite reference to scrollbarDown. | left | Composite reference to scrollbarLeft. | pageDown | Composite reference to scrollbarPageDown. | pageLeft | Composite reference to scrollbarPageLeft. | pageRight | Composite reference to scrollbarPageRight. | pageUp | Composite reference to scrollbarPageUp. | right | Composite reference to scrollbarRight. | up | Composite 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.
Examples
This example uses the doScroll method to scroll down when a button is clicked.
<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 scrolls down when
the "Click to Scroll the Text
Area" button is clicked. The doScroll
method scrolls 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 following icon to install the latest version. Then reload this page to view the sample.
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 Microsoft® Internet Explorer 5 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 method.
Applies To
更多语法参考
componentfrompoint, onscroll