加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 17:49:57 所属栏目:百科 来源:网络整理
导读:静态图片滚动代码: ?? ? var s1 = new SWFObject("focusFlash_fp.swf","mymovie1","415","248","5","#ffffff"); ??????????????????? s1.addParam("wmode","transparent"); ??????????????????? s1.addParam("AllowscriptAccess","sameDomain"); ???????????

静态图片滚动代码:

??? 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",img);
??????????????????? s1.addVariable("smallSrc",url);
??????????????????? s1.addVariable("txt","248");
??????????????????? s1.write("flashFCI");
??????????????? }
??????????????? catch (e) {
??????????????????? alert("返回数据出错,请检查网络。");
??????????????? }
??????????? }

??????????? 页面加载时调用: window.onload=function(){ Post_Ajax();}

??????????? 总结:

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读