Inside JavaScript

Using doScroll

In the Internet Explorer, the doScroll method enables you to simulate a mouse click on a scrollbar using this syntax:

document.body.doScroll([ scrollAction ])

Here, scrollAction is a string that can take one of these values:

  • scrollbarDown . The default. Same as clicking the down scroll arrow.

  • scrollbarHThumb . Clicks the horizontal scroll thumb/box (no scrolling performed).

  • scrollbarLeft . Same as clicking the left scroll arrow.

  • scrollbarPageDown . Scrolls down one page.

  • scrollbarPageLeft . Scrolls left one page.

  • scrollbarPageRight . Scrolls right one page.

  • scrollbarPageUp . Scrolls up one page.

  • scrollbarRight . Same as clicking the right scroll arrow.

  • scrollbarUp . Same as clicking the up scroll arrow.

  • scrollbarVThumb . Clicks the vertical scroll thumb/box (no scrolling performed).

  • down . Same as scrollbarDown .

  • left . Same as scrollbarLeft .

  • pageDown . Same as scrollbarPageDown .

  • pageLeft . Same as scrollbarPageLeft .

  • pageRight . Same as scrollbarPageRight .

  • pageUp . Same as scrollbarPageUp .

  • right . Same as scrollbarRight .

  • up . Same as scrollbarUp .

Here's an example that scrolls a web page downward when the user clicks a button:

(Listing 09-12.html on the web site)

<HTML> <HEAD> <TITLE> Using the doScroll Method </TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- function scroller() { document.body.doScroll("scrollbarDown") } // --> </SCRIPT> </HEAD> <BODY> <H1>Using the doScroll Method</H1> <FORM> <INPUT TYPE="BUTTON" ONCLICK="scroller()" VALUE="Click Me!"> </FORM> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> </BODY> </HTML>

Категории