Random Text and Images


This facility allows you to randomly generate and display text and images on your web pages, each time they are accessed.

n.b.  Only UNIX accounts can use the Random Text or Images scripts.  For NT account holders, will need to create your own random text/image scripts e.g. in ASP.

How do I add Random Text to my web pages ?

To add random text to a particular web page, you will need to initially create a file called random_text.txt in your root directory
i.e. when you FTP into your account, you are taken to the root directory of your web space.

The random.txt file needs to contain all of the text, that will be randomly selected.  

Below is an example of a random.txt file:

Apples
Bananas
Oranges

To display this text randomly we now need to add a Server Side Include (SSI) reference in our HTML code:

<!--#exec cgi="/cgi-bin/random_text"-->

n.b. In order to generate random text, your web page must have the file extension .shtm or .shtml e.g. randomtxt.shtml

Here is an example of randomly generated text (refresh the page to update text):

Random Text test

How do I add Random Images to my web pages?

To randomly display images on your web pages, you will need to create another text file e.g. randomimg.txt

The file needs to contain the path to the image files that are randomly displayed.   If for example you have a specific 'images' directory that stores these files then you will need to use /images/<imagefile>.  Where <imagefile> is the filename for a particular image.

Here is an example of a file, that will randomly display 3 images called image1.gif, image2.gif and image3.gif:

/images/image1.gif
/images/image2.gif
/images/image3.gif

You will then need to add a reference of where you want the images displayed on your web pages:

<IMG SRC="/cgi-bin/random_image/<random file>">

Where <random file> is the filename of your random images file e.g. randomimg.txt

Here is an example of a randomly generated images (refresh the page to update):

Random images test


Back to Webadmin documentation