JavaScript: Scrolling Text

There are two parts to this script. One part will reside in the <HEAD> of your document, and the other will be added to the <BODY>.

To begin, look at scroll.txt. This file contains all the JavaScript you're going to need for this effect. While I can get the sense of what's there, the important thing is that I know where the quote goes. I've inserted the first four lines of Milton's Paradise Lost as the message to be scrolled.

Next, take a look at the Milton Review web page. This will be the web page you'll use for this exercise.

Open up the review.html file in Notepad. You'll be inserting the first piece of JavaScript in the <HEAD>. Looking at scroll.txt, copy everything on the page between the <SCRIPT LANGUAGE="JavaScript"> tag and the </SCRIPT> tag (include both these tags in what you copy to the clipboard). Once you've copied the text, paste it into the <HEAD> section of the Milton Review page.

So far you've copied all the instructions the browser will execute. The last piece to add is what tells the browser to run the script. If you look at scroll.txt again, you'll see some code that's with the <BOD> tag. That's the part to copy, and you'll want to append that text to the <BODY> tag on the Milton Review html page, being careful not to delete or modify other information (like the BACKGROUND information) in the tag.

Save review.html and reload the Milton Review page in your browser. The text should be scrolling across the bottom pane of your browser.

One note: if you read the text scrolling at the bottom, you'll see that two words have been merged. If you go back and look at scroll.txt again, you'll see that the second line of the quote is the only one without a space at the end. This JavaScript is joining each line to the other without a space in between, so remember to put the spaces in yourself, either at the beginning or end of a line.


H O M E B A C K