html代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!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>无标题页</title> <link type="text/css" rel="Stylesheet" href="css/StyleSheet.css" /> <script type="text/javascript" src="js/jquery-1.9.1.js"></script> <script type="text/javascript" language="javascript"> $(document).ready(function(){ //中图广告 var zt_up="<%=ztStr %>"; var zt_up_arr=new Array(); zt_up_arr=zt_up.split(';'); var zt_up_index=0; function UpdateZt_up() { $(".ztgg_container_up img").attr("src",zt_up_arr[zt_up_index]); $(".ztgg_container_down img").attr("src",zt_up_arr[zt_up_index+1]); if(zt_up_index==zt_up_arr.length-2) zt_up_index=0; else zt_up_index=zt_up_index+2; } UpdateZt_up(); window.setInterval(UpdateZt_up,3000); //小图广告 var xtgg="<%=xtStr %>"; var xtgg_arr=new Array(); xtgg_arr=xtgg.split(';'); var xtgg_index=0; var child=$(".xtgg_container").find(".xtgg_container_item"); function updateXt() { for(var i=0;i<child.length;i++) { $(child[i]).find("img").attr("src",xtgg_arr[xtgg_index]); xtgg_index++; } if(xtgg_index==xtgg_arr.length-5) xtgg_index=0; } updateXt(); window.setInterval(updateXt,5000); }); </script> </head> <body> <form id="form1" runat="server"> <div> <div class="gg_container"> <div class="dt_container"> </div> <div class="ztgg_container"> <div class="ztgg_container_up"> <img /></div> <div class="ztgg_container_down"> <img /></div> </div> <div class="login"> </div> <div class="xtgg_container"> <div class="xtgg_container_item" style=" margin-left:0px;"> <img /> </div> <div class="xtgg_container_item"> <img /> </div> <div class="xtgg_container_item"> <img /> </div> <div class="xtgg_container_item"> <img /> </div> <div class="xtgg_container_item" style=" margin-right:0px;"> <img /> </div> </div> </div> </div> </form> </body> </html>
cs代码:
public string ztStr = ""; public string xtStr = ""; protected void Page_Load(object sender, EventArgs e) { ztStr = "img/g1.jpg;img/g2.jpg;img/g3.gif;img/g5.gif"; xtStr = "img/g4.jpg;img/g4.jpg;img/g4.jpg;img/g4.jpg;img/g4.jpg;"; xtStr +="img/g1.jpg;img/g1.jpg;img/g1.jpg;img/g1.jpg;img/g1.jpg;"; xtStr += "img/g8.jpg;img/g8.jpg;img/g8.jpg;img/g8.jpg;img/g8.jpg"; }