Home » » How to create Scrolling Image or Slideshow using Javascript?

How to create Scrolling Image or Slideshow using Javascript?

Written By M.L on திங்கள், 10 அக்டோபர், 2011 | அக்டோபர் 10, 2011

<head runat="server">
    <title>Java Script</title>
    <script type="text/javascript">

        var image1 = new Image()
        image1.src = "firstcar.gif"
        var image2 = new Image()
       image2.src = "secondcar.gif"
        var image3 = new Image()
        image3.src = "thirdcar.gif"
        var image4 = new Image()
        image4.src = "Koala.jpg"

</script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
   <a href="javascript:slidelink()"> <img src="firstcar.gif" name="slide" width="100" height="100" /></a>
    <script>

        //variable that will increment through the images
        var step = 1
        var whichimage = step
        function slideit()
        {
            //if browser does not support the image object, exit.
            if (!document.images)
                return
            document.images.slide.src = eval("image" + step + ".src")
            whichimage = step
            if (step < 4)
                step++
            else
                step = 1
            //call function "slideit()" every 2.5 seconds
            setTimeout("slideit()", 2500)
        }
        slideit()
         function slidelink() {
            if (whichimage == 1)
                window.location = "http://www.google.com"

        }

</script>

   
    </div>
    </form>
</body>

1 comments:

Popular Posts

General Category