This example is set to refresh a random set of images (adverts etcc...) every pre defined number of seconds (i.e refresh=55). The image is inserted as an iFrame using

<iframe name="f" src="rpc.htm" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe>

The basic code for the rpc.htm page is as follows:

Example 1

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="refresh" content="5; url="">
</head>
<body bgcolor="#FFFFFF" text="#000000">

<SCRIPT LANGUAGE="javascript">
<!--

var Path = "graphics/";
// var Path = "";

// Image record is: Filename|Height|Width|Alt-text

Images = new Array(
"1.jpg|97|109|rune 1",
"10.jpg|97|109|rune 10",
"11.jpg|97|109|rune 11",
"12.jpg|97|109|rune 12",
"13.jpg|97|109|rune 13",
"14.jpg|97|109|another rune",
"15.jpg|97|109|another rune",
"16.jpg|97|109|another rune",
"17.jpg|97|109|another rune",
"18.jpg|97|109|another rune"
);
var Path = "graphics/";
// var Path = "";

// Image record is: Filename|Height|Width|Alt-text

Images = new Array(
"1.jpg|97|109|rune 1",
"10.jpg|97|109|rune 10",
"11.jpg|97|109|rune 11",
"12.jpg|97|109|rune 12",
"13.jpg|97|109|rune 13",
"14.jpg|97|109|another rune",
"15.jpg|97|109|another rune",
"16.jpg|97|109|another rune",
"17.jpg|97|109|another rune",
"18.jpg|97|109|another rune"
);

chImg = Math.round(Math.random() * (Images.length -1));

IMGfields = Images[chImg].split("|");

document.write("<img src=\"" + Path + IMGfields[0] + "\"\n");
document.write("height=\"" + IMGfields[1] + "\"\n");
document.write("width=\"" + IMGfields[2] + "\"\n");
document.write("alt=\"" + IMGfields[3] + "\">\n");

// end
//-->
</SCRIPT>

</body>
</html>

The header refresh element changes the picture called at random.

Example 2:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="refresh" content="5; url="">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<script language="javascript" src="rpc.js">
</script>
</body>
</html>

The header refresh element changes the picture called at random. To choose an image file it uses the rpc.js file, as shown in the following example code:

/* PicPics.js - G McMurdo, 19 Mar 01, last-edit 22 Mar 01,
to randomly select from a set of images and write an
HTML IMG tag, also demonstrating 'record handling' */

/* I've set the Path variable so this script will work from
anywhere on our server. If you put the PicsPics.js in the
same directory as your image files, you don't need Path,
and you could comment-out/remove it below, and in the
'document.write()' lines. OR, just swap the commenting
of the two lines below to comment-IN the line which sets
Path to 'null' ... */

var Path = "graphics/";
// var Path = "";

// Image record is: Filename|Height|Width|Alt-text

Images = new Array(
"1.jpg|50|67|Student sits at a PC",
"10.jpg|50|67|Keyboarding at a PC",
"11.jpg|50|67|Bus passing the QM Leith campus",
"12.jpg|50|67|Facade of the Leith Campus",
"13.jpg|50|67|View inside the Leith library",
"14.jpg|50|67|Ship docked in Leith",
"15.jpg|50|67|Bookshelf of library books",
"16.jpg|50|67|Nelson monument on Calton Hill",
"17.jpg|50|67|Students working with PCs",
"18.jpg|50|67|View of the Scott Monument"
);

/* Choose one of the Images array, this time making use
of the 'Images.length' object-property to save us
keeping a count of the number of records we have */

chImg = Math.round(Math.random() * (Images.length -1));

/* Next 'split' the record into 4 elements of the array
IMGfields, so that IMGfields[0] will contain the SRC
field, IMGfields[1] the HEIGHT field, etc ... */

IMGfields = Images[chImg].split("|");

// Now write the SRC, HEIGHT, WIDTH, ALT of the IMG tag

document.write("<img src=\"" + Path + IMGfields[0] + "\"\n");
document.write("height=\"" + IMGfields[1] + "\"\n");
document.write("width=\"" + IMGfields[2] + "\"\n");
document.write("alt=\"" + IMGfields[3] + "\">\n");

// end