Ray's Test Pages - Random JavaScript Poems

What this page does is show how a random poem can be added to a web page using a JavaScript array.

The controlling JavaScript is separate to this page and in the poems.js file. This means that a random poem can be shown on any page with the proper links to poems.js file.

Method 1

This uses poems1.js. It is very inefficient as it uses a separate array for each poem.

Method 2

This uses poems2.js. This is better as it uses a single multidensional array.

Method 3

This uses poems3.js. This uses Method 2, but adds the title and formatting.

The poem titles are kept in a separate array to the poems themselves.

Method 4

This uses poems4.js. This uses Method 2, but adds the title and formatting.

The poem titles are kept in the same array as the poems themselves.

This page created 11th December 2004


GoStats stats counter