zoukankan      html  css  js  c++  java
  • 关于实现banner轮换的问题,如何修改

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

    aspx:

     <div id="bh" runat="server" class="banner" style="margin:0 auto; 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; 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;
            }

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

  • 相关阅读:
    SQL 语法解释器jsqlparser
    《JAVA与模式》之解释器模式
    程序猿应该了解的内容以及程序猿如何强迫自己学习(思考篇)
    强迫自己学习(心态篇),国庆,你准备去哪疯?
    强迫自己学习(实践篇),以及关于写博客的几点建议
    JAVA GC垃圾收集器的分析
    JVM内存模型及内存分配过程
    Extended Traffic LightOJ
    HDU 4616 Game 树形DP
    POJ 3164 Command Network
  • 原文地址:https://www.cnblogs.com/candyzhmm/p/4013093.html
Copyright © 2011-2022 走看看