Sometimes you have to add banner rotator to html sites that is not tied to any network, which is as simple as possible to manage and configure. The code that I present below is very convenient – it is very simple, and should not raise questions.
However – if questions still arise – my mail oleksiy@lavrynenko.com is always at your service! 🙂
-
<div align="center" class="block">
-
<SCRIPT LANGUAGE="JavaScript">
-
<!-- Begin -->
-
var how_many_ads = 3; //number of banners being sorted
-
var now = new Date()
-
var sec = now.getSeconds()
-
var ad = sec % how_many_ads;
-
ad +=1;
-
if (ad==1) {
-
url="Link"; //the address to which the user lands after clicking on the banner
-
alt="Site name";
-
banner="Address-from-load-banner"; //address of the banner image itself
-
width="279";
-
height="233";
-
}
-
if (ad==2) {
-
url="Links"; //the address to which the user lands after clicking on the banner
-
alt="Site name";
-
banner="Address-from-load-banner"; //address of the banner image itself
-
width="279";
-
height="233";
-
}
-
if (ad==3) {
-
url="Links"; //the address to which the user lands after clicking on the banner
-
alt="Site name";
-
banner="Address-from-load-banner"; //address of the banner image itself
-
width="280";
-
height="300";
-
}
-
document.write('<center>');
-
document.write('<a href="' + url + '" target="_top" rel="noopener noreferrer">');
-
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>
-
</p>
-
</div>
As you can see from the presented code – the main load lies on a script that generates a random number in a given range (its size is adjusted manually – the code is working on 12 banners). After generating a random number, a given banner is selected and displayed in a layer.
An example of how the code works is available using the link (each time this page is updated, the picture will change randomly – currently there are links to three pictures in the code).