Display two or more rotating banners (480 x 60) in an infinite loop. Banners also link to advertised URLs.
- Copy the coding into the HEAD of your HTML document
- Add the onLoad event handler into the BODY tag
- Put the last coding into the BODY of your HTML document
<!– STEP ONE: Paste this code into the HEAD of your HTML document –>
<style type=”text/css”>
<!–
#addbox {
position: relative;
width: 500px;
height: 70 px;
clip: rect(0px, 500px, 0px, 70px);
overflow: hidden;
}
#banner1 {
position: relative;
width: 480px;
height: 60px;
left: 0;
top: 5px;
}
#banner2 {
position: relative;
width: 480px;
height: 60px;
left: 500px;
top: -55px !important;
top:-58px;
}
–>
</style>
<script type=”text/javascript”>
<!–
/* This script and many more are available free online at
The JavaScript Source!! http://javascriptsource.com
Created by: Ben Kanaev :: http://www.webhostreview.biz
Adaptation for Netscape and Firefox by Fang */
var displayTime, speed, wait, banner1, banner2, link1, link2, bannerIndex, bannerLocations, bannerURLs;
function initVar() {
displayTime = 10; // The amount of time each banner will be displayed in seconds.
speed = 5; // The speed at which the banners is moved (1 – 10, anything above 5 is not recommended).
wait = true;
banner1 = document.getElementById(“banner1”);
banner2 = document.getElementById(“banner2”);
link1 = document.getElementById(“link1”);
link2 = document.getElementById(“link2”);
banner1 = document.getElementById(“banner1”);
banner2 = document.getElementById(“banner2”);
banner1.style.left = 0;
banner2.style.left = 500;
bannerIndex = 1;
/* Important: In order for this script to work properly, please make sure that the banner graphic and the
URL associated with it have the same index in both, the bannerLocations and bannerURLs arrays.
Duplicate URLs are permitted. */
// Enter the location of the banner graphics in the array below.
bannerLocations = new Array(“internet-lg.gif”,”jupiterweb.gif”,”jupitermedia.gif”);
// Enter the URL’s to which the banners will link to in the array below.
bannerURLs = new Array(“http://www.internet.com”,”http://www.jupiterweb.com”,”http://www.jupitermedia.com”);
}
function moveBanner(){
if(!wait){
banner1.style.left = parseInt(banner1.style.left) – (speed * 5);
banner2.style.left = parseInt(banner2.style.left) – (speed * 5);
if(parseInt(banner1.style.left) <= -500){
banner1.style.left = 500;
bannerIndex = (bannerIndex < (bannerLocations.length – 1)) ? ++bannerIndex :0;
banner1.src = bannerLocations[bannerIndex];
link1.href = bannerURLs[bannerIndex];
wait = true;
}
if(parseInt(banner2.style.left) <= -500){
banner2.style.left = 500;
bannerIndex = (bannerIndex < (bannerLocations.length – 1)) ? ++bannerIndex :0;
banner2.src = bannerLocations[bannerIndex];
link2.href = bannerURLs[bannerIndex];
wait = true;
}
setTimeout(“moveBanner()”,100);
} else {
wait = false;
setTimeout(“moveBanner()”, displayTime * 1000);
}
}
–>
</script>
<!– STEP TWO: Insert the onLoad event handler into your BODY tag –>
<BODY onLoad=”initVar(); moveBanner()”>
<!– STEP THREE: Copy this code into the BODY of your HTML document –>
<div align=”center”>
<div name=”addbox” id=”addbox”>
<a name=”link1″ id=”link1″ href=”http://www.internet.com”><img border=”0″ name=”banner1″ id=”banner1″ src=”internet-lg.gif”></a>
<a name=”link2″ id=”link2″ href=”http://www.jupiterweb.com”><img border=”0″ name=”banner2″ id=”banner2″ src=”jupiterweb.gif”></a>
</div></div>
<p><center>
<font face=”arial, helvetica” size”-2″>Free JavaScripts provided<br>
by <a href=”https://javascriptsource.com”>The JavaScript Source</a></font>
</center><p>