Return to Snippet

Revision: 51449
at September 24, 2011 19:39 by jamepaul


Initial Code
<html>
<head>
    <title>Sliding Images</title>
    <script type="text/javascript">
        //Create images Array
        var imgArr = new Array("images/img1.jpg",
                    "images/img2.jpg",
                    "images/img3.jpg");
                    
        var count = imgArr.length; // assign images array length
        var position = 0; //position is set to zero
        
        function slidingImages() {
            if ( document.images ) {
                if ( position < count ) {
                    imageSrc(position); // call the image source
                    position += 1;
                } else {
                    position = 0;
                    imageSrc(position);
                }
            }
            setTimeout(slidingImages, 3000);
        }

        function imageSrc(position) {
            document.banner.src = imgArr[position];
        }
    </script>
</head>
<body onload="slidingImages()">
    <img src="images/img1.jpg" name="banner"/>
</body>
</html>

Initial URL

                                

Initial Description

                                

Initial Title
Simple image slider with pure javascript

Initial Tags
javascript

Initial Language
JavaScript