JavaScript: Random Quotes

This JavaScript is similar to the Scrolling Text JavaScript since it has one part (mostly the instructions) contained in the <HEAD> of the document and one part (telling the script where to write the text) in the <BODY>. The script randomly picks between (in this case) 22 strings of text and prints one on the page. Apparently this can work for images and sounds as well, though I've not tried this script against those media.

If you examine the file random.txt you will find both halves of this script. The quotes in the file are those I'm currently using on my home page. We'll add them to this page. Copy all of the script that's contained in the <HEAD> section of the text file and paste it into the HTML for this page (open the code for the page in Notepad). If you like you can make changes to the quotes I'm using, just to see the changes.

Next, copy the script that will be inserted into the <BODY> of this page and paste it just above the first paragraph. Save the file and reload the page in your browser. And reload. And reload.

Like the script for Today's Date, you can format the text produced by the script by enclosing the script itself in the formatting tags you want to use.


H O M E B A C K