Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

Randomly rotating banner

Code Wizard, 12-30-2006

Randomly select an image from an array and display it with an <img> tag. Useful as an advertisement rotator. (Credit: apress.com)

<script type="text/javascript">
var bannerImages = new Array();
bannerImages[0] = "Banner1.jpg";
bannerImages[1] = "Banner2.jpg";
bannerImages[2] = "Banner3.jpg";
bannerImages[3] = "Banner4.jpg";
bannerImages[4] = "Banner5.jpg";
bannerImages[5] = "Banner6.jpg";
bannerImages[6] = "Banner7.jpg";
var randomImageIndex = Math.round(Math.random() * 6);
document.write("<img alt="" src="" + bannerImages[randomImageIndex] + "">");
</script>
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions