JavaScript City



Random Quote on Page

This script will allow you to display a random quote on the page.

Script Code

Grab a copy of the file below and place it in the same directory as the Web page on which you will use the script (if you wish to place the script file in a different directory you will need to make the necessary adjustments to the src attribute of the script tag that calls it).

smisc1.js

The code below should be placed between the <body> and </body> tags where you want the clock to appear.

Example

A working sample of the script is shown below. Refresh the page for a new random quote.

Options

You can change the appearance of the quote by adding the my_quote id to your style sheet and editing as desired.

Additional quotes can be added to the random quote set by editing the JavaScript code. Example code to add an 11th quote:

quote[0]="Starting right meow?";
quote[1]="It\'s got electrolytes.";
quote[2]="Just wanted to let you know- we\'re all counting on you.";
quote[3]="What\'s the matter Colonel Sanders? Chicken?";
quote[4]="Rodents of Unusual Size? I don't think they exist.";
quote[5]="You keep using that word. I do not think it means what you think it means.";
quote[6]="Inconceivable!";
quote[7]="Nooooooooooooooo!";
quote[8]="Try not. Do or do not. There is no try.";
quote[9]="Gosh!";
quote[10]="New quote text.";

If you need to use single or double quotation marks within a quote, you should write them with a backslash before them (i.e. \" and \') in order to avoid JavaScript errors.

Also, the number in brackets ([10] in this case) needs to be increased by one for each quote added.

Accessibility

A backup to the script via Java applet or some type of plugin is a possibility. If the plugin is accessible, a link for the viewer to download the plugin somewhere on the page should suffice. A server-side script that displays a random quote would also be a possibility.



eXTReMe Tracker