Sunday, 25 March 2012

java script code to display photos that changes after few seconds.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="AdRedirect.aspx.vb" Inherits="AdRedirect" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"> 
        <title>Image</title>
        <script type="text/javascript">
            var picPaths = ['pic1.jpg','pic2.jpg','pic3.jpg','pic4.jpg','pic5.jpg'];
            var curPic = -1;
            //preload the images for smooth animation
            var imgO = new Array();
            for(i=0; i < picPaths.length; i++) {
                imgO[i] = new Image();
                imgO[i].src = picPaths[i];
            }
 
            function swapImage() {
                curPic = (++curPic > picPaths.length-1)? 0 : curPic;
                imgCont.src = imgO[curPic].src;
                setTimeout(swapImage,2000);
            }
 
            window.onload=function() {
                imgCont = document.getElementById('Image1');
                swapImage();
            }
        </script>
 
    </head>
    <body>
 
        <div>
            <asp:Image ID="Image1" runat="server" Width="147px" />
        </div>
 
    </body>
</html> 

No comments:

Post a Comment