|
Need to have banners that
randomly rotate on a page in your web site? Here's an efficient
javascript that will do the trick automatically for you. Simply
copy the text below and insert it in the appropriate spot in the
<body> section of your page. To see the sample here working
just hit the refresh button on your browser.
Here's the
key for changing variables in the text to match your needs:
- var how_many_ads = n; where n is
the number of ads you will rotate
- txt="..."; this is the
text that appears below the banner (you can remove this line if
you wish not to include a banner text)
- url="..."; this is the
link address of the banner
- alt="..."; this is the
text that will appear in replace of the banner in case the banner
does not load (this also appears when you move your mouse over the
banner)
- banner="..."; this is the
url of the banner image to be rotated
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var how_many_ads = 4;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
if (ad==1) {
txt="The premier spam stopping program.";
url="http://entier.ecosm.com/system/redir.php?ad=7&aid=2426";
alt="Mailwasher";
banner="http://entier.ecosm.com/system/img.php?ad=7&aid=2426";
width="468";
height="60";
}
if (ad==2) {
txt="Low Cost Internet Connections For
Your Home.";
url="http://click.linksynergy.com/fs-bin/click?id=X2ggM6VpaFE&offerid=57464.10000116&type=4&subid=0";
alt="Low Cost Internet";
banner="http://www.gtctelecom.com/banners/isp_1399_468x60.gif";
width="468";
height="60";
}
if (ad==3) {
txt="Use the same software used by commercial
companies to promote your web site to the search engines"
url="http://www.trellian.com/swolf/?id=100597";
alt="SubmitWolf Pro";
banner="http://www.GLBTWebHost.com/images/SubmitWolfPro.gif";
width="468";
height="60";
}
if (ad==4) {
txt="Google: the worlds most popular
search engine";
url="http://www.google.com";
alt="Google";
banner="http://google.com/banner.gif";
width="468";
height="60";
}
document.write('<center>');
document.write('<a href=\"' + url + '\" target=\"_top\">');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('<small>' + txt + '</small></a>');
document.write('</center>');
// End -->
</SCRIPT>
If you want
to add more banners, just copy the whole if (ad==?){...}, paste
it after the fourth if(add==4){...} statement and replace the ?
with 5 and so on.
|