You can use the scroll , scrollBy , and scrollTo methods to scroll a window's content. Here's how you use these methods : window.scroll( iX , iY ) window.scrollBy( iX , iY ) window.scrollTo( iX , iY ) Here are the arguments of these methods:
Here's an example that uses the scroll method to scroll a window when the user clicks a button: (Listing 08-08.html on the web site)<HTML> <HEAD> <TITLE> Scrolling Windows </TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- function scroller() { window.scroll(0, 100) } // --> </SCRIPT> </HEAD> <BODY> <H1>Scrolling Windows</H1> <FORM> <INPUT TYPE="BUTTON" ONCLICK="scroller()" VALUE="Click Me!"> </FORM> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> <BR> </BODY> </HTML> Actually, the scroll method has been more or less replaced by the scrollTo method these dayswhich does the same thingalthough the scroll method is still available. The Netscape Navigator also supports two handy methods scrollByLines and scrollByPages that enable you to scroll by a given number of lines and pages. |