SMF Ads Support Forum

Support => Ad Support => Topic started by: AMBA on August 26, 2006, 02:36:08 pm

Title: Java Code
Post by: AMBA on August 26, 2006, 02:36:08 pm
I sell space on my forum, we are a parenting site for parents of twins triplets and more, so I use my own ads custom made for my forum. Here is the java I use to display them.

Code: [Select]
<script language="JavaScript">

i = 4 // Number of banners that you have
banner1 = new Image();
banner1.src = "image one here";
banner2 = new Image();
banner2.src = "image two here";
banner3 = new Image();
banner3.src = "image three here";
banner4 = new Image();
banner4.src = "image four here";



links = new Array
links[1] = "url 1"
links[2] = "url 2"
links[3] = "url 3"
links[4] = "url 4"



text = new Array
text[1] = "alt text"
text[2] = "alt text"
text[3] = "alt text"
text[4] = "alt text"

function randombanner(){
var randomnumber = Math.random();
i = Math.round( (i - 1) * randomnumber) + 1;
document.banner.src = eval("banner" + i + ".src");
}

function startTime(){

        var time= new Date();
        hours= time.getHours();
        mins= time.getMinutes();
        secs= time.getSeconds();
        closeTime=hours*3600+mins*60+secs;
        closeTime+=5;
        Timer();

}

function Timer(){
        var time= new Date();
        hours= time.getHours();
        mins= time.getMinutes();
        secs= time.getSeconds();
        curTime=hours*3600+mins*60+secs
        if (curTime>=closeTime){
                if (i < 4){
                        i++;
                        document.banner.src = eval("banner" + i + ".src");
                }
                else{
                        i = 1;
                        document.banner.src = eval("banner" + i + ".src");
                }
                startTime();
        }
        else{
                window.setTimeout("Timer()",1000)}

}

function clickLink(){
        top.location = links[i]
}

function descript(){
        window.status = description[i]
}

// -->

</script>

<body onLoad="randombanner(); startTime();">

<center><a href="your url here" onClick="clickLink(); return false;" onMouseOver="descript(); return true;" onMouseOut="window.status=''"><img src="your imgar here" border=0 name="banner"></a></center>
Title: Re: Java Code
Post by: jerm on August 26, 2006, 04:29:18 pm
so the problem is it doesn't display?
Title: Re: Java Code
Post by: AMBA on September 18, 2006, 06:20:39 am
no no it works. I'm just sharing it with others.
Title: Re: Java Code
Post by: bigguy on September 18, 2006, 07:24:52 pm
Thats great thanks AMBA for the code. ;)
Title: Re: Java Code
Post by: vatso on August 27, 2007, 07:21:08 am
Is there anyway a person can make it that it only uploads one random pic at a time & does not scroll?

if so how does one do that

Thanks inadvance - nice Java stuff