1. Home
  2. Computing & Technology
  3. JavaScript

Vertical Scroller

2. Obtain the Script

clr gif
Join the Discussion

Questions? Comments?

More of this Feature

Introduction Add to your Page

To add scroll boxes to your web page you first need to copy the Javascript code into the head section of your page.

Copy the above Javascript and save it to an external file. I called mine scroller.js.

We can now link the Javascript into the head of our web page using the following code:

<script type="text/javascript" src="scroller.js"></script>

You will notice that there is a function at the top of the script called addScrollers. This function should contain one startScroll function call for each scroller that you want to place on your web page. The startScroll function requires two parameters. The first parameter is a unique name to identify the particular scroller. The second parameter is the scrolling content of that scroll box. The code includes two example startScroll functions so if you only need one you should edit the first and remove the second.

If necessary you can also increase the scroll speed by increasing the value assigned to speed. You can also set the scrollers to scroll down instead of up by setting dR = true.

Now all that remains is to add the divs to your page where you want the scrollers to appear.

Explore JavaScript
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.