Home Advanced Code Keep Your Site Looking Fresh With Rotating Images

Keep Your Site Looking Fresh With Rotating Images

E-mail Print PDF
1.) You will need 6 graphics that are preferably the same size.

2.) Upload those images to a directory on your website.

3.) Place this piece of code below your opening body tag:

Code:
 
<script language="JavaScript" type="text/javascript">
// This script is free to use
<!--
// JavaScript to interpolate random images into a page.
var ic = 6; // Number of alternative images
var xoxo = new Array(ic); // Array to hold filenames

xoxo[0] = "http://www.yourdomain.com/whereimagesare/image1.gif";
xoxo[1] = "http://www.yourdomain.com/whereimagesare/image2.gif";
xoxo[2] = "http://www.yourdomain.com/whereimagesare/image3.gif";
xoxo[3] = "http://www.yourdomain.com/whereimagesare/image4.gif";
xoxo[4] = "http://www.yourdomain.com/whereimagesare/image5.gif";
xoxo[5] = "http://www.yourdomain.com/whereimagesare/image6.gif";

function pickRandom(range) {
if (Math.random)
return Math.round(Math.random() * (range-1));
else {
var now = new Date();
return (now.getTime() / 1000) % range;
}
}
// Write out an IMG tag, using a randomly-chosen image name.
var choice = pickRandom(ic);
// -->
</script>
4.) Place this piece of code where you'd like the graphics to show on yoru website: (change the width and height to your preference)

Code:
<SCRIPT LANGUAGE="JavaScript">
document.writeln('<TD'+'>
<IMG src="/'
+xoxo[choice]+'" HEIGHT=184 WIDTH=120 BORDER=0 >
<'
+'/TD>');</SCRIPT>

 

Domain Names

Sample image .com .info
.mobi .net
.org .tv .us
.biz .ws .name
.am .at .be .cc .cn .de .eu
.fm .jobs .jp .ms .nu .nz
.tc .tw .uk .vg .ASIA .ME

Website Hosting

Sample image We're the affordable, reliable place to host your site. And unlike the competition, there's no set up fee and no annual commitment.

24/7 Support

Sample image Our highly trained, courteous support staff is waiting to help. We'll resolve any issue to your complete satisfaction.