swfobject.js结合flash.swf插件显示前台图片滚动

静态图片滚动代码:

    var s1 = new SWFObject("focusFlash_fp.swf", "mymovie1", "415", "248", "5", "#ffffff");
                    s1.addParam("wmode", "transparent");
                    s1.addParam("AllowscriptAccess", "sameDomain");
                    s1.addVariable("bigSrc", "../images/01.jpg|../images/02.jpg|../images/03.jpg|../images/04.jpg|../images/05.jpg");
                    s1.addVariable("smallSrc", "|../images/06.jpg|||");
                    s1.addVariable("href",
"http://www.lanrentuku.com|http://www.lanrentuku.com|http://www.lanrentuku.com|http://www.lanrentuku.com|http://www.lanrentuku.com";);
                    s1.addVariable("txt", "");
                    s1.addVariable("width", "415");
                    s1.addVariable("height", "248");
                    s1.write("flashFCI");

     得出插件能自动分割'|'字符, 上面是滚动5张图片,点击图片到指定URL.

     后台设置前台滚动的图片;

        Info_BLL info_bll = new Info_BLL();
        StringBuilder sb = new StringBuilder();
        foreach (RepeaterItem rs in info_list.Items)
        {
            CheckBox cb = (CheckBox)rs.FindControl("CheckBox2");
            if (cb.Checked)
            {
                Label info_id = (Label)rs.FindControl("info_id");
                sb.Append("update web_info set info_scroll = 1 where info_id = '" + info_id.Text + "' ");
            }
        }
        if (sb.Length>10)
        {
            if (MyHelpSql_SqlServer.SqlReturnLine(sb.ToString()) > 0)
            {
                Page_();
                MessageBox.Show(this, "设置滚动成功。");
            }
        }
        else
        {
            MessageBox.Show(this, "请选择要操作的数据。");
        }

        前台代码:(试用异步获取数据)

           function Post_Ajax() {
            try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                xmlhttp = new XMLHttpRequest();
            }
            if (xmlhttp != null) {
                xmlhttp.open("Post", "http://localhost:52440/Project_UI/Page_Ajax/Test.ashx", false);
                xmlhttp.onreadystatechange = OnMessageBack;
                xmlhttp.send(null);
            } else {
                alert("您的预览器不支持xmlhttp对象,请升级预览器");
            }
        }

        Test.ashx里代码:

          string url = "";
          string img="";
          DataTable dt = new Project_BLL.Info_BLL().SelUrlImg_Info();
          foreach (DataRow row in dt.Rows)
          {
              img += "../Uploads/" + row["img_name"].ToString() + "|";
              url += "/Project_UI/Page_H/JST_NewDetailed.aspx?info_id=" + row["info_id"].ToString() + "_menu_id=" + row["menu_id"].ToString() + "|";       
         }
         context.Response.Write(img+"$"+url);
         context.Response.End();

         

           处理异步返回的数据:

            function OnMessageBack() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                try {
                    html = "";
                    html = xmlhttp.responseText;
                    var str = html.split('$');
                    var img = str[0];
                    var url = str[1];
                    url = url.substring(0, url.length - 1);
                    img = img.substring(0, img.length - 1);
                    var s1 = new SWFObject("focusFlash_fp.swf", "mymovie1", "415", "248", "5", "#ffffff");
                    s1.addParam("wmode", "transparent");
                    s1.addParam("AllowscriptAccess", "sameDomain");
                    s1.addVariable("bigSrc", img);
                    s1.addVariable("smallSrc", "|../images/06.jpg|||");
                    s1.addVariable("href", url);
                    s1.addVariable("txt", "");
                    s1.addVariable("width", "415");
                    s1.addVariable("height", "248");
                    s1.write("flashFCI");
                }
                catch (e) {
                    alert("返回数据出错,请检查网络。");
                }
            }

            页面加载时调用: window.οnlοad=function(){ Post_Ajax();}

            总结:

                        主要是配置img,url两个值 . 插件会按'|'来解析 . 自己在后台把读取出来的img,url拼接好. 前台异步获取. 记得截取掉最后一个字符.

 

       

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值