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 http://tj4119.blogspot.com/
// Ad your images, links and title here

// e.g. 'ad1.jpg','www.link1.com','Title Goes here',

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

randomAd([
'ad1.jpg','link1','title1',
'ad2.jpg','link2','title2',
'ad3.jpg','link3','title3'
]);

// DO NOT EDIT ANYTHING BELOW

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="www.tj4119.blogspot.com" 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.

1 comment:

  1. Hey that's really a great post and a wonderful description out here, I really like the way things are being executed and discussed here.

    Classified Ads Software

    ReplyDelete