Nov 10, 2011

How to display images with a delay of five seconds


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>
Related posts:

0 comments:

Post a Comment

Your comments:

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More