News:

Version 3.5 has been released. Visit https://custom.simplemachines.org/mods/index.php?mod=255 to get the most up to date version.

Main Menu
Coinbase

Java Code

Started by AMBA, August 26, 2006, 03:36:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

AMBA

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.

<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>

jerm

so the problem is it doesn't display?

AMBA

no no it works. I'm just sharing it with others.

bigguy

Thats great thanks AMBA for the code. ;)

vatso

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