View Full Version : Banner rotation
Crazy Mofo
04-18-2002, 10:40 PM
sorry too brin this subject up again but i couldnt find a script that changes every 10th time that u visit any1 got any ideas?
If not anyone got a good java script that just changes the the banner i only want it too change between the 2 changing each time u visit the site not every 20 secs blah blah..
Thx
Crazy
Crazy Mofo
04-19-2002, 02:04 AM
cmon there must be some j-script wizard :confused:
wooolF[RM]
04-19-2002, 01:14 PM
<a href="http://www.spoono.com/codebase/php/?link=Ad" target="_blank">http://www.spoono.com/codebase/php/?link=Ad</a>
Crazy Mofo
04-19-2002, 09:26 PM
cool but that aint really javascript :(
wooolF[RM]
04-20-2002, 12:45 AM
u don't need JavaScript... why use it? PHP is much better
Crazy Mofo
04-20-2002, 01:28 AM
yea but i want too add the script too the top ov me style
Pilot
04-20-2002, 05:26 PM
// banner rotate in JS
var currentdate = 0;
var core = 0;
function initArray() {
this.length = initArray.arguments.length;
for (var i = 0; i < this.length; i++) {
this[i] = initArray.arguments[i];
}
}
function getRandomNum(lbound, ubound) {
return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}
rand = getRandomNum(10000,999999);
// Array of links and images
link = new initArray(
"/cgi-bin/ads.pl?banner=NonSSI;page="+rand+"",
"/cgi-bin/ads.pl?banner=NonSSI;page="+rand+"",
"http://kansas.valueclick.com/redirect?host=XXXXXXX&size=468x60&b="+rand+"&v=0");
image = new initArray(
"/cgi-bin/ads.pl?page="+rand+"",
"/cgi-bin/ads.pl?page="+rand+"",
"http://kansas.valueclick.com/cycle?host=XXXXXXX&size=468x60&b="+rand+"&noscript=1");
var currentdate = new Date();
var secs = currentdate.getSeconds();
var core = secs % image.length;
var ranlink = link[core];
var ranimage = image[core];
var text = "Click to visit advertiser (a new window will open)";
document.write('<center><a href=\"' +ranlink+ '\" target=\"_blank\">');
document.write('<img src=\"'+ranimage+'\" border=0 width=468 height=60 alt=\"'+text+'\"></a></center>');
Pilot
04-20-2002, 05:28 PM
The above JS will select a URL link and image randomly from an array in the code. In my case I use it simply to select from an internal banner ad system and an external one. The rand variable is a randomiser for the ad systems and is not required for simple banner ad rotation.
I call the JS from a template but keep the JS in a server file so that it can be easily changed.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.