Skip to main content

Posts

Showing posts from July, 2010

How to randomly displaying images on page refresh

This script display images in "imageRot" div randomly on every page load. Replace "quote-xx.gif" with your image name. <div id="imageRot"></div> <script type="text/javascript"> var images = new Array(); images.push("quote-01.gif"); images.push("quote-02.gif"); images.push("quote-03.gif"); images.push("quote-04.gif"); images.push("quote-05.gif"); images.push("quote-06.gif"); images.push("quote-07.gif"); var random = Math.floor(Math.random() * 7); var imageRot = document.getElementById("imageRot"); imageRot.innerHTML = '<img src="images/' + images[random] + '" alt="">'; </script>