• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

15. Dynamic Content Applications > 15.5. Auto-Scrolling the Page

Auto-Scrolling the Page

NN 4, IE 4

Problem

You want the entire browser page to automatically scroll vertically for the user.

Solution

With their Version 4 releases, Internet Explorer and Netscape Navigator empowered their window objects with a scrollBy( ) method. By invoking it repeatedly through a setInterval( ) call, you can scroll the browser window with no user interaction. The following function and setInterval( ) call do the trick:

function scrollWindow( ) {
    window.scrollBy(0, 1);
}
function initScroll( ) {
    setInterval("scrollWindow( )", 100);
}

The initScroll( ) function should be invoked by the onload event handler of the body element.

Discussion


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint