Forum Moderators: open

Message Too Old, No Replies

rotating images on homepage

i want to create a bank of images for homepage

         

cdell100

2:39 am on Jan 21, 2002 (gmt 0)

10+ Year Member



I'm hoping to create a bank of images that would rotate when a visitor goes to the homepage of a particular site. This seems like it would be a relatively simple task, but I can't quite figure it out. Any ideas?

Tapolyai

2:50 am on Jan 21, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You are running Apache with PHP (if we are talking about your profile website).

Do you want the image to rotate one after an other without refresh, or do you just one random static image every time the page gets loaded?

Marshall

3:20 am on Jan 21, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This will rotate as many images as you want, with or without a link, at whatever speed you set.

<head>
<script type="text/javascript">
bName = navigator.appName;
bVer = parseInt(navigator.appVersion);
if((bName == "Netscape" && bVer >=3) ¦¦
(bName == "Microsoft Internet Explorer" && bVer >= 4)) br = "n3";
else br = "n2";

if (br =="n3") {
boardNum = 0;
boardspeed = 2000; /* 1000 equals 1 second */

billboards = new Array(); /* You can add as many images as you want */
bilboards[0] = new Image();
billboards[0].src = "new_image.gif";
bilboards[1] = new Image();
billboards[1].src = "new_image_1.gif";
bilboards[2] = new Image();
billboards[2].src = "new_image_2.gif";

url = new Array(); /* You can add this if you want the images to link to pages */
url[0] = "url.htm";
url[1] = "url.htm";
url[2] = "url.htm";
}
function rotateBoard() {

if (boardNum < billboards.length - 1) boardNum++;
else boardNum = 0;
document.billboard.src = billboards[boardNum].src;
setTimeout('rotateBoard()', boardSpeed);
}

function jumpBillboard() { /* This is for the link if used */
window.location.href = url[boardNum];
}
</script>
</head>

<body onload="if(br=='n3') setTimeout('rotateBoard()',boardSpeed)">

<!-- The billboard image and link NOTE All images have to be the same size -->
<a href="javascript:jumpBillboard()"><img name="billboard" src="new_image.gif border="0" height="n" width="n"></a>

minnapple

3:42 am on Jan 21, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member


Try this from Matt's scripts
http://www.worldwidemart.com/scripts/image.shtml

justa

4:37 am on Jan 21, 2002 (gmt 0)

10+ Year Member



This will put a different image each time you reload the page.

<script language="JavaScript">
<!--
var how_many_ads = 6;

var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;

if (ad==1) {
alt="PRIME definition"; banner="images/photos/prime1.gif";
width="400";
height="250";
}
if (ad==2) {
alt="PRIME definition"; banner="images/photos/prime2.gif";
width="400";
height="250";
}
if (ad==3) {
alt="PRIME definition";
banner="images/photos/prime3.gif"; width="400"; height="250";
}
if (ad==4) {
alt="PRIME definition";
banner="images/photos/prime4.gif";
width="400";
height="250";
}
if (ad==5) {
alt="PRIME definition";
banner="images/photos/prime5.gif";
width="400";
height="250";
}
if (ad==6) {
alt="PRIME definition";
banner="images/photos/prime6.gif";
width="400";
height="250";
}
document.write('<center>');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('</center>');
// -->
</script>

cdell100

5:35 pm on Jan 22, 2002 (gmt 0)

10+ Year Member



Thanks for the scripts. I grabbed all three and am playing around with them to see what seems to work the best for me. I appreciate the help!

mivox

6:41 pm on Jan 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might want to do a search for "banner rotator"... Any script that will load a different banner every time a page is loaded could be easily used for other images.