Simulates a click on a scroll bar component.
Syntax
object.doScroll(component)Parameters
- component [in, optional]
-
Type: Variant
A String that 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
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Standards information
There are no standards that apply here.
Remarks
As of a Windows Store app using JavaScript, this method is supported only for webpages displayed in a Windows Store app using JavaScript. For webpages displayed in standards mode (preferred), use the scrollLeft and scrollTop properties.
The doScroll method is available on all objects, regardless of whether they support scrollbars.
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
The following example uses the doScroll method to scroll down when a button is clicked.
<head>
<script type="text/javascript">
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>
The following example uses the doScroll method to scroll down a text area in one-second intervals.
<head>
<script type="text/javascript">
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>
See also
- a
- abbr
- address
- area
- b
- base
- bdo
- blockQuote
- body
- br
- button
- caption
- cite
- code
- col
- colGroup
- comment
- custom
- dd
- del
- div
- dl
- dt
- em
- embed
- fieldSet
- form
- head
- hn
- hr
- html
- i
- iframe
- img
- input type=button
- input type=checkbox
- input type=file
- input type=hidden
- input type=image
- input type=password
- input type=radio
- input type=reset
- input type=submit
- input type=text
- ins
- kbd
- label
- legend
- li
- link
- map
- object
- ol
- option
- p
- pre
- q
- rt
- ruby
- s
- samp
- script
- select
- small
- span
- strong
- sub
- sup
- table
- tBody
- td
- textArea
- tFoot
- th
- tHead
- title
- tr
- u
- ul
- var
- Reference
- componentFromPoint
- onscroll
Build date: 11/28/2012