Click to See Complete Forum and Search --> : How can I center this banner code for a forum?


LUTRELLA
11-16-2006, 05:08 PM
How can I center this banner code for a forum?
The banners appear on the page, but they are on the left, and i can't figure out how to center this code!


<if condition="$forumid == 77">
<script language="JavaScript">
<!--
function adArray() {
for (i=0; i*2<adArray.arguments.length; i++) {
this[i] = new Object();
this[i].src = adArray.arguments[i*2];
this[i].href = adArray.arguments[i*2+1];
}
this.length = i;
}
function getAdNum() {
dat = new Date();
dat = (dat.getTime()+"").charAt(8);
if (dat.length == 1)
ad_num = dat%ads.length;
else
ad_num = 0;
return ad_num;
}


var ads = new adArray(
"images/banners/Alaska Wildfowl_Bouchrd.jpg","http://www.akduckhunts.com",
"images/banners/LewisOutdoorAdvturesbanner.gif","http://www.lewisoutdooradventures.com",
"images/banners/StormOutfittersbanner.jpg","http://www.stormoutfitters.com");

var ad_num = getAdNum(); // don't change this line

document.write(''
+''
+'<BR>'
+'<A HREF="'+ads[ad_num].href+'"><IMG SRC="'+ads[ad_num].src+'" '
+'BORDER=0 name=js_ad>');

// ****** YOU NEED NOT MODIFY ANYTHING THAT IS NOT IN BETWEEN THESE TWO COMMENTS ****

link_num = document.links.length-1;

function rotateSponsor() {
if (document.images) {
ad_num = (ad_num+1)%ads.length;
document.js_ad.src = ads[ad_num].src;
document.links[link_num].href = ads[ad_num].href;
setTimeout("rotateSponsor()",45000);
}
}
setTimeout("rotateSponsor()",45000);

// -->
</script>
</if>

WebJoel
11-16-2006, 05:26 PM
Surround the script with a <div> </div>, give the DIV a WIDTH, and MARGIN:0 auto;

<div style="width:75%; margin:0 auto">

"script here"

</div>

That should work. You will need to determine if the width "75%" is too much, too little, etc., but you MUST declare a width, or else the margin:0 auto will not work to center this.

The margin:0 ("margin:zero") is the space "above" the DIV, and "auto" will subtract the WIDTH of the DIV from the user's screen-width, and divide up what is remaining equally to the right & left margins... centered! :)