Banner Rotation

You can find out about the best adverts for your websites' target group with banner rotation. You'll find out there are huge differences in what kind of banners, text-links and also in the different types of products you present to your target group.

Of course there are a lot of killer apps out there to manage advertising campaigns. But if you operate a small website an easy JavaScript will do.

So here is our JavaScript solution you can easily integrate in your website. It enables you to randomly rotate five different banners.

Open an empty text document with your editor which you later on will save as "rotation-script.js". Then copy and paste the following code.



function randInt(min,max)
{
     var div = (max - min) + 1
     var randNum = Math.random()
     for (var i = 0; i <= div - 1; i++)
     {
          if (randNum >= i / div && randNum < (i+1) / div)
          {return i + min}
     }
}


var abc = randInt(1,5);

if (abc == 1) {

     document.write("<\"Your 1. HTML-Banner-Code\">");

}

if (abc == 2) {

     document.write("<\"Your 2. HTML-Banner-Code\">");

}

if (abc == 3) {

     document.write("<\"Your 3. HTML-Banner-Code\">");

}

if (abc == 4) {

     document.write("<\"Your 4. HTML-Banner-Code\">");

}

if (abc == 5) {

     document.write("<\"Your 5. HTML-Banner-Code\">");

}




Documentation:

The function "randInt" is called to define a random number from 1 to 5. Then the script writes the HTML-Code of one of your banners to your website. It is that easy!

Always use backslashes in your HTML-Code when you use the JavaScript function "document.write("");" to write to your pages.

As stated above save the text file as "rotation-script.js". You can integrate this script in your HTML-documents with:

<script language="JavaScript" type="text/javascript" src="rotation-script.js">




Be careful to read through the terms and conditions of advertisers. Some do not allow to run banner rotation scripts on your website.

If you can code in PHP you can find more advanced scripts at HotScripts.com