Sunday, October 31, 2010

Simple Ad Rotator Script

Sorry I was offline 4 some time but that time gave me some thought & I went creative. I designed 30 web-templates ready to B sold. But also have created a simple script to rotate image banners.

It is not required if U use Google™ Adsense, but if U have your own ads than It'll B very useful. It is simple to use & doesn't requires any database or PHP.

So if U want it then here it is.

// Ad rotator script created by Tanmay Das
// Script © Copyright, Tanmay Das
// Visit
// Ad your images, links and title here

// e.g. 'ad1.jpg','','Title Goes here',

// DO NOT PUT a (,) at the end



function random(limit){
return Math.floor(Math.random()*limit);

function randomAd(imgArr)
var imgSrc, imgW, imgH, imgUrl, imgTit, r;
r = random(imgArr.length / 3);
imgSrc = imgArr[r * 3];
imgW = 180; // You can change the ad width
imgH = 150; // You can change the ad height
// I decided that all D banners in one area of a site will B of D same size, so I made the size universal 4 all.
imgUrl = imgArr[(r * 3)+1];
imgTit = imgArr[(r * 3)+2];

document.write('<a href='+imgUrl+' title='+imgTit+' target=_blank><IMG SRC='+imgSrc+' WIDTH='+imgW+' HEIGHT='+imgH+'></a><br><a href="" title="Created By Tanmay Das" target="_blank">Designed By Tanmay Das</a>');

Just save it as adfile.js and add the link to anywhere on your site where U want the ads.
Remember that all the banners should B of D same size & change the width & height at imgW &imgH.