Random Banner Rotation Script
There are two scripts. One in the body of page at the place you want the banner to appear and one in the head (or in an externally linked .js file if you prefer).
This main script sets up an array of banners, much like the array you would use for rollovers.
var banner=new MakeBannerArray(max);
for (var i=1; i<=n;i++)
Every banner requires all the HTML to display that banner to be put into an array element. You should, of course, substitute your own link URL and the path to your image file in each instance. The easiest way to do this is to insert the actual banner on the page and copy and paste the HTML into the script inside single quotes.
banner='<a href="--- link URL ---"><img src="--- path to image file ---" width="468" height="60" alt="whatever"><\/a>';
banner='<a href="--- link URL ---"><img src="--- path to image file---" width="468" height="60" border="0" alt="whatever"><\/a>';
banner='><a href="--- link URL ---"><img src="--- path to image file ---" width="468" height="60" alt="whatever"><\/a>';
To generate the random number, I use this little routine which generates a random number between 1 and max.
Finally, the function that is called from the page and pulls it all together is just this:-
The script that goes on the page looks like this:-
The setBanner() function generates a random number and passes a random array element back to the document.write (banner[thisBanner]); statement which prints it to the page at the point where the script resides.