Loading and Displaying the banner Advertisement



write a JavaScript code to change the images in banner.


<html>
  <head>
    <script>

        banner_array = new Array('vegetables1.jpg','vegetables2.jpg','vegetables3.jpg','vegetables4.jpg')
        banner = 0;

        function DisplayBanners() 
        { 
            if (document.images) 
            {
                banner ++;
            
                if (banner == banner_array.length) 
                {
                    banner = 0;
                }
                document.ChangeBanners.src = banner_array[banner];
                setTimeout("DisplayBanners()",300)
            }  
        }

    </script>
  </head>

<body onload="DisplayBanners()">

    <center>
         <img src="vegetables1.jpg" width="500" height="220" name="ChangeBanners" />         
    </center>
  </body>
</html>

Output: