Rotating Banner to Your Site or Blog

Javascript Banner Rotator

The use of a banner rotator can be used for several purposes. A couple of examples would be to give your site a fresh look by rotating your site logo, and showing your site sponsors advertisement banners in a certain location within a page.

The tutorial below will teach you how to create your own banner rotator script using javascript. At present the script is set to rotate 3 different banners and place the banner at the center of the top of the page. However with some modifications to the javascript code you can change this to suit your needs.

Please visit the webmaster forum if you experience any problems.

Select all (Ctrl + A) the text script below and copy it to your clipboard (Ctrl + C).

Open a your webpage that you want your rotating banners to appear on, in a program such as Wordpad or Notepad and paste the above text (Ctrl + V) in the location that you want your banners to appear.

Edit the RED text only to reflect your information.



<SCRIPT LANGUAGE="JavaScript">

<!-- BANNER ROTATOR

var how_many_ads = 3
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;

//***************** AD NUMBER ONE ****************

if (ad==1){

url="http://www.youradvertiser.com";

alt="Advertiser Number One";

banner="http://www.yourdomain.com/images/banner1.gif";

width="468";
height="60";
}

//***************** AD NUMBER TWO ****************

if (ad==2){

url="http://www.youradvertiser.com";

alt="Advertiser Number Two";

banner="http://www.yourdomain.com/images/banner2.gif";

width="468";
height="60";
}

//***************** AD NUMBER THREE ****************

if (ad==3){

url="http://www.youradvertiser.com";

alt="Advertiser Number Three";

banner="http://www.yourdomain.com/images/banner3.gif";

width="468";
height="60";
}

document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_blank\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('</center>');
-->
</SCRIPT>


After you have embedded the script into your page within the <body> tags, where you want your banners to appear you are ready to upload
your pages!

Got Something to Add?
0 comments: Post a Comment

Older Post