View Full Version : rotating banner in a table
muchi_us
09-03-2002, 05:39 AM
I need to make a rotating banner in a table cell. Each of the banners (4) has an other link to an other website. Didi somebody knows a script for this ?
Thank you
Markus
x_goose_x
09-03-2002, 05:59 AM
<script>
ads = new Array();
ads[0] = "pic1.jpg-http://www.site1.com";
ads[1] = "pic2.jpg-http://www.site2.com";
ads[2] = "pic3.jpg-http://www.site3.com";
ads[3] = "pic4.jpg-http://www.site4.com";
function loader() {
ad = Math.round(Math.random()*(ads.length-1));
document.getElementById("adimag").src = ads[ad].substring(0,ads[ad].indexOf("-"));
popurl = ads[ad].substring(ads[ad].indexOf("-")+1,ads[ad].length);
}
window.onload = loader;
</script>
<img src="" id="adimag" onclick="window.open(popurl);">
muchi_us
09-03-2002, 06:12 PM
Thank you x-goose-x for your help. I know this random selected banner script, what I am looking for, is this script, but all banners rotate in a certain time (e.g. every 15 seconds, an other banner shows up and will have a link to there website).
Thank you
Markus
x_goose_x
09-03-2002, 08:28 PM
<script>
ads = new Array();
ads[0] = "pic1.jpg-http://www.site1.com";
ads[1] = "pic2.jpg-http://www.site2.com";
ads[2] = "pic3.jpg-http://www.site3.com";
ads[3] = "pic4.jpg-http://www.site4.com";
x = 0
function loader() {
document.getElementById("adimag").src = ads[x].substring(0,ads[x].indexOf("-"));
popurl = ads[x].substring(ads[x].indexOf("-")+1,ads[x].length);
if (x+1>=ads.length){
x=0;
}else{
x++;
}
}
setInterval("loader()",15000);
</script>
<img src="" id="adimag" onclick="window.open(popurl);">
muchi_us
09-04-2002, 09:24 PM
Thanks again x_goose_x. Your script is working, but I can post only one script on a page, as sooen I post the script twice, it does not work. So I found an other script :
<head>
<script language="JavaScript">
var imagenumber = 4 ;
var randomnumber = Math.random() ;
var rand = Math.round( (imagenumber-1) * randomnumber) + 1 ;
image = new Array
image[1] = "image01.jpg"
image[2] = "image02.jpg"
image[3] = "image03.jpg"
image[4] = "image04.jpg"
var image = image[rand]
</script>
</head>
<body>
<script type="text/javascript" language="JavaScript">
var image = image[rand]
if(image == image[1]) document.write("<a href='http://www.url1.com'><img src='image01.jpg'></a>");
if(image == image[2]) document.write("<a href='http://www.url2.com'><img src='image02.jpg'></a>");
if(image == image[3]) document.write("<a href='http://www.url3.com'><img src='image03.jpg'></a>");
if(image == image[4]) document.write("<a href='http://www.url4.com'><img src='image04.jpg'></a>");
</script>
</body>
Did you know, how to implant here the random ?
Thanks
Markus
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.