This script cycles four images. It is very similar to the Cycling Banner featuring Calvin Hobbes, with two exceptions: (1)document.adBanner.complete is used to ensure that the pictures are available prior to cycling the image; and (2) instead of Calvin, these are old images of me. No laughing!

Source Code:

<!--
MODULE NAME: /javascript/week4/fourimages.cfm
PURPOSE: Assignment 3, week 4.
REFERRING MODULE(S): whiteboard_iframe.cfm
DESTINATION MODULE(S):
QUERYSTRING METHODS SUPPORTED:
AUTHOR: Grant Szabo (grant@quagmire.com) Sterling Creek Software
CREATED: 12/17/02
LAST MODIFIED: 12/17/02
-->

<html>
<head>
<title></title>

<script language="JavaScript">

adImages = new Array("/images/grant94.gif", "/images/grant.gif", "/images/grant.jpg", "/images/grant2001.jpg");
thisAd = 0;
imgCt = adImages.length

function fcnRotate() {
	if(document.images) {
		if(document.adBanner.complete) {
			thisAd++;
			if(thisAd == imgCt) {
				thisAd = 0;
				}
			document.adBanner.src=adImages[thisAd];
			setTimeout("fcnRotate()", 3 * 1000);
			}
		}
}							
</script>							

</head>

<body onLoad="fcnRotate();">

<center>
<img src="http://www.quagmire.com:80/images/grant94.gif" name="adBanner">
</center>	

</body>
</html>