doScroll method
[doScroll is no longer supported. Starting with Internet Explorer 11, use scrollLeft or scrollTop. For info, see Compatibility changes.]
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.
-
Default. Down scroll arrow is at the specified location.
-
Horizontal scroll thumb or box is at the specified location.
-
Left scroll arrow is at the specified location.
-
Page-down scroll bar shaft is at the specified location.
-
Page-left scroll bar shaft is at the specified location.
-
Page-right scroll bar shaft is at the specified location.
-
Page-up scroll bar shaft is at the specified location.
-
Right scroll arrow is at the specified location.
-
Up scroll arrow is at the specified location.
-
Vertical scroll thumb or box is at the specified location.
-
Composite reference to scrollbarDown.
-
Composite reference to scrollbarLeft.
-
Composite reference to scrollbarPageDown.
-
Composite reference to scrollbarPageLeft.
-
Composite reference to scrollbarPageRight.
-
Composite reference to scrollbarPageUp.
-
Composite reference to scrollbarRight.
-
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 Windows Internet Explorer 9, this method is supported only for webpages displayed in IE5 (Quirks) mode. 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.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/doScrollEX.htm
<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.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/doScrollEX1.htm
<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
- acronym
- address
- applet
- area
- b
- base
- baseFont
- bdo
- bgSound
- big
- blockQuote
- body
- br
- button
- caption
- center
- cite
- code
- col
- colGroup
- comment
- custom
- dd
- del
- dfn
- dir
- div
- dl
- dt
- em
- embed
- fieldSet
- font
- form
- frame
- frameSet
- head
- hn
- hr
- html
- i
- iframe
- img
- input type=button
- input type=checkbox
- input type=email
- input type=file
- input type=hidden
- input type=image
- input type=number
- input type=password
- input type=radio
- input type=range
- input type=reset
- input type=search
- input type=submit
- input type=tel
- input type=text
- input type=url
- ins
- isIndex
- kbd
- label
- legend
- li
- link
- listing
- map
- marquee
- menu
- nextID
- noBR
- noFrames
- noScript
- object
- ol
- option
- p
- plainText
- pre
- q
- rt
- ruby
- s
- samp
- script
- select
- small
- span
- strike
- strong
- sub
- sup
- table
- tBody
- td
- textArea
- tFoot
- th
- tHead
- title
- tr
- tt
- u
- ul
- var
- wbr
- xml
- xmp
- Reference
- componentFromPoint
- onscroll