以下是一段JavaScript代码实现的图片播放功能,但我现在要实现的是可以动态的更改图片的路劲,此路径在数据库某一表的字段中已经存储,该如何实现呢?
<script type="text/javascript"> 
imgUrl1="http://www.fansart.com/qiehuan/1.jpg"; //这是第一张广告图片 
imgtext1="图片说明" 
imgLink1=escape("跳转地址"); 
imgUrl2="http://www.fansart.com/qiehuan/2.jpg"; //这是第二张广告图片 
imgtext2="" 
imgLink2=escape("跳转地址"); 
imgUrl3="http://www.fansart.com/qiehuan/3.jpg"; //这是第三张广告图片 
imgtext3="" 
imgLink3=escape("跳转地址"); 
imgUrl4="http://www.fansart.com/qiehuan/4.jpg"; //这是第四张广告图片 
imgtext4="" 
imgLink4=escape("跳转地址"); 
imgUrl5="http://www.fansart.com/qiehuan/5.jpg"; //这是第五张广告图片 
imgtext5="" 
imgLink5=escape("跳转地址"); 
var focus_width=207 
var focus_height=156 
var text_height=0
var swf_height = focus_height+text_height var pics=imgUrl1+"|"+imgUrl2+"|"+imgUrl3+"|"+imgUrl4+"|"+imgUrl5 
var links=imgLink1+"|"+imgLink2+"|"+imgLink3+"|"+imgLink4+"|"+imgLink5 
var texts=imgtext1+"|"+imgtext2+"|"+imgtext3+"|"+imgtext4+"|"+imgtext5 
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="'+ focus_width +'" height="'+ swf_height +'">'); 
document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="http://www.webjx.com/js/focus.swf"><param name="quality" value="high"> <param name="bgcolor" value="#F0F0F0">'); 
document.write('<param name="menu" value="false"><param name=wmode value="opaque">'); 
document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight=' +focus_height+'&textheight='+text_height+'">'); 
document.write('<embed src="pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight= '+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#F0F0F0" quality="high" width ="'+ focus_width +'" height="'+ focus_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>'); 
</script> 

解决方案 »

  1.   


     <script type="text/javascript">
        <!--
        var focus_width=759
        var focus_height=210
        var text_height=18
        var swf_height = focus_height+text_height
        <%string ps="";string ls="";string ts="";
        for(i=0;i<imgTab.Rows.Count;i++) 
        {
        ps+="admincenter/upload/"+imgTab.Rows[i]["Img"].ToString()+"|";
        ls+=imgTab.Rows[i]["URL"].ToString()+"|";
        ts+=imgTab.Rows[i]["Title"].ToString()+"|";
        } %>
        var pics='<%=ps %>';
        var links='<%=ls %>'
        var texts='<%=ts %>'
        if(pics.lastIndexOf("|")==pics.length-1){
            pics=pics.substring(0,pics.lastIndexOf("|"))
        }
        if(links.lastIndexOf("|")==links.length-1){
            links=links.substring(0,links.lastIndexOf("|"))
        }
        if(texts.lastIndexOf("|")==texts.length-1){
            texts=texts.substring(0,texts.lastIndexOf("|"))
        }
    var banner='<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="images/banner.swf"><param name="quality" value="high">'
        
        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="'+ focus_width +'" height="'+ swf_height +'">');
        document.write(banner);
        document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
        document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
        document.write('</object>');
        
        //-->
                            </script>protected int i;
        protected DataTable imgTab = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            imgTab = BDB.GetTab("select * from ChgImg order by ID");
        }
      

  2.   

    参考这个,看行吗?
    http://www.cnblogs.com/insus/articles/1377591.html
      

  3.   

    你的方法可行:
    但现在遇到一个问题:我的网站程序页面上有一个flash图片,在设计母版时,我嵌入了flash图片连环播放的代码,已经确认代码无异常,但是问题是,通过点击浏览首页时falsh不显示。我后台程序有一个链接是链接到首页的。而通过这个链接进入首页,首页却可以显示。
    另外,我如果不使用母版,而是直接放在index.aspx中又可以显示出来!
    我觉得问题就出现在母版页是否不可以放flash?
    或者说是 在程序调用的时候还需要 某个配置?
      

  4.   

    前台放一个label或literal 把JS代码在后台赋给这个literal