当前位置:编程学习 > C#/ASP.NET >>

asp.net中后台向前台javascript传值,下面贴出代码

<script language='javascript' type="text/javascript">
            linkarr = new Array();
            picarr = new Array();
            textarr = new Array();
            var swf_width=269;
            var swf_height=210;
            var img1="pic.jpg";
            var img2="pic1.jpg";
            var img3="pic2.jpg";
            var img4="pic3.jpg";
            var files = "images/"+img1+"|images/"+img2+"|images/"+img3+"|images/"+img4+"";
            var links = "#|#|#|#";
            var texts = "";
            for(i=1;i<picarr.length;i++){
              if(files=="") files = picarr[i];
              else files += "|"+picarr[i];
            }
            for(i=1;i<linkarr.length;i++){
              if(links=="") links = linkarr[i];
              else links += "|"+linkarr[i];
            }
            for(i=1;i<textarr.length;i++){
              if(texts=="") texts = textarr[i];
              else texts += "|"+textarr[i];
            }
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase=" http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ swf_width +'" height="'+ swf_height +'">');
            document.write('<param name="movie" value="images/indexpic.swf"><param name="quality" value="high">');
            document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
            document.write('<param name="FlashVars" value="bcastr_file='+files+'&bcastr_link='+links+'&bcastr_title='+texts+'">');
document.write('<embed src="images/indexpic.swf" wmode="opaque" FlashVars="bcastr_file='+files+'&bcastr_link='+links+'&bcastr_title='+texts+'& menu="false" quality="high" width="'+ swf_width +'" height="'+ swf_height +'" type="application/x-shockwave-flash" pluginspage=" http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>');
          </script>

以上是用JS通过四张图片生成swf文件显示在网页中,定义的img1,img2,img3,img4,是图片的名称,是写死的,我现在想在后台实现更改,怎样在后台把图片的名字穿到这个JS上,asp,net网站

答案:后台
public string img1;
public string img2;
public string img3;
public string img4;

前台
  var img1="<%=img1%>";
            var img2="<%=img2%>";
            var img3="<%=img3%>";
            var img4="<%=img4%>";


<%=某字符串%>用来替换那些个imgN

某字符串 是后台计算出来的,就OK了啊

上一个:求ASP+正则表达式代码 过滤HTML中href标签和图片的代码
下一个:在ASP上用HTML语言做一个日期显示的代码是什么?

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,