Pages

Sunday, 30 September 2012

Picture Album Auto Change Using Java script

Picture album is very important part of the web development
mostly developer  attached their organization picture on website.We see these pictures change
automatically.I always want to do this,after searching many website i got a simple
solution to  make it. Their are many standard way to achieve it. But my solution is tricky..
If you have fix number of image on your site then my code is useful for you, I renamed all my image
into serial number 1,2....... n
I used Timer on every tick of timer i changed the image's relative path
HTML Code...
 <html >
<head >
    <title>Girfa Album Timer Demo</title>


    <script language=javascript>
        var i=0;      
        function sstart()
        {
            var ob=document.getElementById('img1');
            if(i>4)
            {
               i=1;
            }
            ob.src=i+".jpg";
            i++;
            setTimeout("sstart()",3000);
        }
       
    </script>

</head>
<body onload="sstart()">
    <form>
             <img src="1.jpg" height="200px" width="200px" id="img1" />          
    </form>
</body>
</html>

No comments:

Post a Comment