关于实现banner轮换的问题,如何修改

最近遇到了这样的问题,本来banner都是gif格式的,但是现在要求上传图片格式为jpg时,运用JS实现动画效果,原来的也能用。

aspx:

 <div id="bh" runat="server" class="banner" style="margin:0 auto; width:950px;margin-bottom:5px;"> <a href='http://www.3456.tv/business/<%=companyoname %>/' target="_blank"> <img src ="<%=companybanner %>" alt="<%=companyname %>" title="<%=companyname %>"  height="<%=imgheight%>"/> </a> </div>

      <SCRIPT language=javascript type=text/javascript>

    var imgUrl = new Array();

    var Com_Banners = '<%=topImg%>';

    var strs = new Array(); //定义一数组

    strs = Com_Banners.split("|"); //字符分割 

    for (var i = 0; i <= strs.length - 1; i++) {

        imgUrl[i + 1] = strs[i];

    }

    var picNum = 1;

    var counts = strs.length;

    //自动切换图片代码  

    function NextPic() {

        var pic = document.getElementById("ShowImg");

        var button = document.getElementById("banner").getElementsByTagName("div");

        if (document.all) {

            pic.filters.revealTrans.Transition = Math.floor(Math.random() * 23);

            pic.filters.revealTrans.apply();

            pic.filters.revealTrans.play();

        }

        pic.src = imgUrl[picNum];

        picNum++;

        if (picNum > counts) {

            picNum = 1;

        }

        //设置翻页时间

        theTimer = setTimeout("NextPic()", 3000);

    }

 </SCRIPT>

  <div id="banner" runat="server" style="margin:0 auto; width:950px;display:<%=backdis%>;">

        <a href='http://www.3456.tv/business/<%=companyoname %>/' target="_blank"><img style="FILTER:revealTrans(duration=2,Transition=5)" id="ShowImg" width="950" src="<%=showImg%>" alt="<%=companyname%>"/></a>

     </div>

<SCRIPT type=text/javascript>NextPic();</SCRIPT>

aspx.cs:

        //头部banner

            if (companybanner.Equals(""))

            {

                bh.Visible = false;

                banner.Visible = false;

            }



            else

            {

                companybanner = dt.Rows[0]["BusBanner"].ToString();

                string[] arraylist = companybanner.Split('|');

                if (arraylist.Length > 1)

                {

                    topImg = dt.Rows[0]["BusBanner"].ToString();

                    showImg = topImg.Substring(0, topImg.IndexOf("|"));

                    banner.Visible = true;

                    bh.Visible = false;

                }

                else

                {

                    topImg = dt.Rows[0]["BusBanner"].ToString();

                    string houzhui = topImg.Substring(companybanner.LastIndexOf(".") + 1).ToLower().ToString();

                    if (houzhui == "jpg")

                    {

                        bh.Visible = false;

                        //imgHeight = "200";

                        backdis = "none";

                        banner.Visible = true;

                    }

                    else

                        bh.Visible = true;

                    banner.Visible = false;

                }

            }

        }

        else

            Response.Redirect("http://www.3456.tv/404.htm");

        if (topImg != "")

        {

            topImg = dt.Rows[0]["BusBanner"].ToString();

            //判断

            string[] arraylist = topImg.Split('|');

            if (arraylist.Length > 1)

            {

                banner.Visible = true;

                bh.Visible = false;

            }

            else

            {

                string houzhui = topImg.Substring(companybanner.LastIndexOf(".") + 1).ToLower().ToString();

                if (houzhui == "jpg")

                {

                    bh.Visible = false;

                    //imgHeight = "200";

                    backdis = "none";

                    banner.Visible = true;

                }

                else

                    bh.Visible = true;

                    banner.Visible = false;

            }

            type = companyoname;

        }

修改后台文件时,注意声明好变量。

你可能感兴趣的:(问题)