呵呵 ^。^  
我在做一个图片显示,要做成图片自动切换的那种效果。
图片是通过后台上传的(已经做好了),但在网上找了些代码,没弄出来。
具体怎么做呀,有代码嘛?贴出来研究研究

解决方案 »

  1.   

    遍历整个图片文件夹。将fullName做成数组。用timer定时修改img的src
      

  2.   

    我给你个,想做成动态的就用JS结合后台给他赋值<script type=text/javascript>
                    <!--
                    //var nPic = new Array(),nPiclink=new Array(),nPicTit=new Array(),preloadedimages=new Array();
                    var nPic = new Array(),nPiclink=new Array(),preloadedimages=new Array();
                    var nPicNum=0;
                    nPic[0]="../nntcn_image/pic/shua1.gif";
                    nPiclink[0]="#";
                
            preloadedimages[1]=new Image();
                    preloadedimages[1].src=nPic[0];//Modify2008-03-28 Author:xinghai.li
                    nPic[1]="../nntcn_image/pic/gg200809.gif";
                    nPiclink[1]="#";
            preloadedimages[2]=new Image();
                    preloadedimages[2].src=nPic[1];//Modify2008-03-28 Author:xinghai.li
                    nPic[2]="../nntcn_image/pic/gg3.gif";
                    nPiclink[2]="#";
                    preloadedimages[3]=new Image();
                    preloadedimages[3].src=nPic[2];//Modify2008-03-28 Author:xinghai.li
                    nPic[3]="../nntcn_image/pic/gg2.gif";
                    nPiclink[3]="#";                function setTransition(){
                        if(document.all) {
                            document.getElementById('nPicRotator').filters.revealTrans.Transition=23;
                            document.getElementById('nPicRotator').filters.revealTrans.apply();
                        }
                    }
                    function playTransition(){
                        if(document.all){
                            //alert("nPicRotator" + document.getElementById('nPicRotator'));
                            document.getElementById('nPicRotator').filters.revealTrans.play();
                        }
                    }
                    function nextAd(){
                        if(nPicNum < nPic.length-1){
                            nPicNum++;
                        } else {
                            nPicNum=0;
                        }
                        midWay();
                        theTimer=setTimeout("nextAd()",4000);
                    }
                    function midWay(){
                    setTransition();
                    document.getElementById('nPicRotator').src=nPic[nPicNum];
                    document.getElementById('nPicRotatorA').href=nPiclink[nPicNum];
                    
                    playTransition();
                    }
                    theTimer=setTimeout("nextAd()",4000);
                    //-->
                    </script>
      

  3.   

    Default.aspx<form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick">
                    </asp:Timer>
    你要干的事情......(Interval设置成你想要的频率)
                </ContentTemplate>
            </asp:UpdatePanel>
        </form>Default.aspx.csprotected void Timer1_Tick(object sender, EventArgs e)
        {
    //你想干的事情,如调用WebService等......
        }
      

  4.   

    http://blog.csdn.net/laolaowhn/archive/2008/07/25/2711301.aspx
      

  5.   

    楼主,我是被你忽悠进来的,你可一定要给分啊至于你的问题,我给个小小的意见:
    你可以把要循环显示的图片命名成连续的,比如:
    1.jpg,2.jpg,3.jpg,4.jpg......
    然后,你可以每次通过一个随机函数,得到一个值,对应到某一个图片
    还有关于切换的时间间隔,你可以用一个定时器控制
      

  6.   

    這個我有。
    首先是用ajax把圖片名字取出來 然后
    用js 添加到html中
    然后就是js代碼控制自動切換了:
    var widths=650;              
    var heights=365;              
    var counts=arr.length-1;   
    var nn=0;
    var key=0;
    function change_img()
    {if(key==0){key=1;}
    else if(document.all)
    {document.getElementById("pic").filters[0].Apply();document.getElementById("pic").filters[0].Play(duration=2);}
     document.getElementById("pic").src=arr[nn];
     
     document.getElementById("url").href="#";
     
    for (var i=1;i<=counts;i++){document.getElementById("xxjdjj"+i).className='axx';}
    document.getElementById("xxjdjj"+nn).className='bxx';
    nn++;if(nn>counts){nn=0;}
    tt=setTimeout('change_img()',4000);}
    function changeimg(n){nn=n;window.clearInterval(tt);change_img();}
     var td=document.getElementById("AlbumScroll");td.innerHTML+='<div align=right style="width:'+widths+'px;overflow:hidden;text-overflow:clip;">';
    td.innerHTML+='<div><a id="url"><img id="pic" style="border:0px;filter:progid:dximagetransform.microsoft.wipe(gradientsize=1.0,wipestyle=4, motion=forward)" width='+widths+' height='+heights+' /></a></div>';
    td.innerHTML+='<div style="filter:alpha(style=1,opacity=10,finishOpacity=80);background: #888888;width:100%-2px;text-align:right;top:-12px;position:relative;margin:1px;height:12px;padding:0px;margin:0px;border:0px;">';
    for(var i=0;i<counts+1;i++){document.write('<a href="javascript:changeimg('+i+');" id="xxjdjj'+i+'" class="axx" target="_self"></a>');}
    document.write('</div></div>');
    change_img();
    function stop()
    {
      clearTimeout(tt);
    }function starts()
    {
      tt=setTimeout('change_img()',4000);
    }
    </SCRIPT>
      

  7.   

    這個是頁面放在頁面里的<div align="right" STYLE="width:90%">
    <table border=0 width="100%" align="right">
    <tr>
    <td>
     <div  id="AblumTitle" border=0 align="left"  valign="bottom">
    </td>
    <td align="right" valign="bottom">
    <input type="button" onclick="starts();" value="start"/>
    <input type="button" onclick="stop();" value="stop"/>
    </td>
    </tr>
    <tr>
    <td colspan="2" id="AlbumScroll" valign="top">
     <hr size="0" noshade="noshade" color="#000" >
    </td>
    </tr>
    </table>=======================
    這是取圖片 放在數組里
     var arr=new Array();
    function CrearHtml()
    { AlbumID=GetRequest("AlbumID"); if(AlbumID!=undefined)
        {    var  returnValue=getPhotoMemoAndName(AlbumID);
     
     
      
       var returnNewName=returnValue[0].split(",");

     

     
     
     
     
    if(returnNewName!=undefined)
    {
        
     
      for(i =0;i<returnNewName.length-1;i++)
      {
     
      var src="Object/Album/big/"+returnNewName[i];
      arr.push(src);
       
        }
    }
    else

         
      //  cell.innerHTML+="<td width='60' ><span class='標題'>此相薄無相片</span></td>";
      

    }
    }
     } 
      

  8.   

    lz你很像XX地方拉客的!!----这个我是用flash来做的。
    在flash里新建一个xml对象(ActionScript脚本),load一个url地址。
    这个url地址可以是一个静态的xml文件,也可以是一个asp.net的页面。
    不管是什么,输出出来应该是一个xml格式的内容,也就是说这个URL地址输入到浏览器查看,应该是一个xml文档。
    内容示例:
    <items>
    <item src="AdBoard/2009calendar.jpg" seconds="4" ref="http://news.sohu.com" />
    <item src="AdBoard/2.jpg" seconds="4" ref="http://reader.google.com" />
    <item src="AdBoard/3.jpg" seconds="4" ref="http://www.google.com" />
    <item src="AdBoard/4.jpg" seconds="4" ref="http://www.baidu.com" />
    </item>
    这个xml文档的格式是完全又你自己设计的,这只是一个例子。flash的xml对象读取了这个文档之后,就有了N组图片地址和链接地址,以及播放/停留时长,
    然后就按这个开始做一个滚动播放的flash吧。
    然后就完工了。用flash来做需要会一些ActionScript,如果flash比较NB,做出来会有相应的NB的效果。----
    如果不用flash,用JS也可以.
    用JS其实个人觉得更简单一些。但是JS没办法实现flash无止境的完美效果(取决于flash制作人的NB程度)。