Friday, 7 December 2012

Display Image With 5 Second Delay Using Javascript


Display Image With 5 Second Delay Using Javascript

With this script you can see clickable images rotating in real-time without requiring banner rotation software or page reloads/refreshes .You should see a new banner rotating every 5 seconds:


    <%@ Page Language="C#" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>JavaScript</title>
        <script language="javascript" type="text/javascript">
        var image="";
        var banners=0;
        function loadbanners() {
       if (banners==1)
          {
             image="images/AJAX.gif";
          }
       if (banners==2)
          {
             image="images/ASPDotNet.gif";
          }
       if (banners==3)
          {
             image=" images/MSDN.gif";
          }
          }
          function cycle() 
          {
            if (++banners > 3) 
            banners=1;
            loadbanners();
            document.getElementById("banner1").src =image;
            window.setTimeout('cycle();',5000);
          }
        </script>
    </head>
    <body onload="cycle();">
        <form id="form2" runat="server">
        <div>
            <img alt="" id="banner1" src="images/start.png" />
        </div>
        </form>
    </body>
    </html>


Reference:

No comments:

Post a comment

Thank You for Your Comments. We will get back to you soon.

back to top