1. 论坛系统升级为Xenforo,欢迎大家测试!
    排除公告

求~~一JS代码 做图片轮换的效果?

本帖由 小白2005-09-28 发布。版面名称:前端开发

  1. 小白

    小白 New Member

    注册:
    2005-09-25
    帖子:
    1,604
    赞:
    9
    想做一个图片轮换的效果~~

    不知道什么样的JS代码可以实现啊?
     
  2. 秋天的虫子

    秋天的虫子 New Member

    注册:
    2005-09-04
    帖子:
    402
    赞:
    1
    var imgUrl=new Array();
    var imgLink=new Array();
    var adNum=0;


    imgUrl[1]="照片.gif";
    imgLink[1]="#";

    imgUrl[2]="照片.gif";
    imgLink[2]="#";
    var imgPre=new Array();
    var imgj=0;

    for (imgi=1;imgi<3;imgi++)
    {

    if( (imgUrl[imgi]!="") && (imgLink[imgi]!="") )
    {

    imgj++;

    }
    else
    {

    break;

    }
    }

    function playTran()
    {

    if (document.all)

    {
    imgInit.filters[0].Apply();

    imgInit.filters[0].Play(duration=2);

    }


    }

    var key=0;

    function nextAd()
    {
    if(adNum<imgj)adNum++ ;
    else adNum=1;
    if( key==0 )
    {
    key=1;
    }
    else if (document.all)
    {

    playTran();

    }
    document.images.imgInit.src=imgUrl[adNum];
    theTimer=setTimeout("nextAd()", 4000);
    }

    function goUrl()
    {
    jumpUrl=imgLink[adNum];
    jumpTarget='_blank';
    if (jumpUrl != '')
    {
    if (jumpTarget != '') window.open(jumpUrl,jumpTarget);
    else
    location.href=jumpUrl;
    }
    }
     
  3. wm_chief

    wm_chief New Member

    注册:
    2005-09-05
    帖子:
    17,890
    赞:
    46
    不错!。其实可以看sina.com.cn
     
  4. 老林

    老林 New Member

    注册:
    2005-09-06
    帖子:
    10,580
    赞:
    36
    ---------------------------
    <SCRIPT language=Javascript>
    var bannerAD=new Array();
    var bannerADlink=new Array();
    var bannerADtarget=new Array();
    var adNum=0;


    <!-- 图像1 -->
    bannerAD[1]="http://www.mjj.com/1.gif";

    <!-- 图像2 -->
    bannerAD[2]="http://www.mjj.com/2.gif";

    <!-- 图像3 -->
    bannerAD[3]="http://www.mjj.com/3.gif";

    <!-- 图像4 -->
    bannerAD[4]="http://www.mjj.com/4.gif";

    <!-- 图像5 -->
    bannerAD[5]="http://www.mjj.com/5.gif";

    <!-- 图像可加 -->


    var preloadedimages=new Array();
    for (i=1;i<bannerAD.length-1;i++){
    preloadedimages=new Image();
    preloadedimages.src=bannerAD;
    }

    function setTransition(){
    if (document.all){
    bannerADrotator.filters.revealTrans.Transition=12;
    bannerADrotator.filters.revealTrans.apply();
    }
    }


    function playTransition(){
    if (document.all)
    bannerADrotator.filters.revealTrans.play()
    }

    function nextAd(){
    if(adNum<bannerAD.length-1)adNum++ ;
    else adNum=1;
    setTransition();
    document.images.bannerADrotator.src=bannerAD[adNum];
    playTransition();
    theTimer=setTimeout("nextAd()", 3800);
    }

    function jump2url(){
    jumpUrl=bannerADlink[adNum];
    jumpTarget=bannerADtarget[adNum];

    if (jumpUrl != ''){
    if (jumpTarget != '')window.open(jumpUrl,jumpTarget);
    else window.open(jumpUrl,"","toolbar=yes,location=yes,directories=yes,status=yes,scrollbars=yes,resizable=yes");
    }
    }
    function displayStatusMsg() {
    status=bannerADlink[adNum];
    document.returnValue = true;
    }
    </SCRIPT>
    ---------------------------

    以下加入到<Body>之间

    ----------------------------

    <IMG
    style="FILTER: revealTrans(duration=1,transition=12)" height=189
    src="http://www.mjj.com/1.gif" ... 0name=bannerADrotator>
    <SCRIPT language=JavaScript>nextAd()</SCRIPT>
     
  5. 老林

    老林 New Member

    注册:
    2005-09-06
    帖子:
    10,580
    赞:
    36
    再来一个

    <BODY onload=AlphaBar();>


    <SCRIPT>
    var IE5=null;
    if(navigator.userAgent.indexOf("IE 5.0")>-1) IE5=true;
    else IE5=false;

    function ImgTrans()
    {
    if(IE5==false)
    {
    var Filter=new Array(
    "progid:DXImageTransform.Microsoft.Fade(Duration=1)",//变化样式
    "progid:DXImageTransform.Microsoft.Wipe(Duration=2 , GradientSize=1.0, wipeStyle=0, motion='forward')",
    "progid:DXImageTransform.Microsoft.Wipe(Duration=2 , GradientSize=1.0, wipeStyle=0, motion='reverse')",
    "progid:DXImageTransform.Microsoft.Pixelate(Duration=1 , MaxSquare=25)"
    )
    var FilterIndex=Math.ceil(Math.random()*1000)%Filter.length;
    imgObj.style.filter=Filter[FilterIndex];
    imgObj.filters[0].apply();
    imgObj.src = imgSwapObj.src;
    imgObj.filters[0].play();
    }
    else
    {
    imgObj.style.filter="revealtrans(duration=1,transition=23)";
    imgObj.filters[0].transition=23;
    imgObj.filters[0].apply();
    imgObj.src = imgSwapObj.src;
    imgObj.filters[0].play();
    }
    }
    </SCRIPT>

    <SCRIPT>AlphaBarImage=new Array(6);
    AlphaBarLink=new Array(6);
    AlphaBarImage[0]="1.jpg";
    AlphaBarLink[0]="1111111.htm";
    AlphaBarImage[1]="2.jpg";
    AlphaBarLink[1]="1111111.htm";
    AlphaBarImage[2]="3.jpg";
    AlphaBarLink[2]="1111111.htm";
    AlphaBarImage[3]="4.jpg";
    AlphaBarLink[3]="1111111.htm";
    AlphaBarImage[4]="5.jpg";
    AlphaBarLink[4]="1111111.htm";
    AlphaBarImage[5]="6.jpg";
    AlphaBarLink[5]="1111111.htm";
    </SCRIPT>

    <SCRIPT>
    var AlphaBarIndex=0;
    function AlphaBar()
    {
    imgSwapObj.src="images/"+AlphaBarImage[AlphaBarIndex];//-------设定路径
    AlphaBarLinkHref.href=AlphaBarLink[AlphaBarIndex];
    ImgTrans();
    AlphaBarIndex++;
    if (AlphaBarIndex%6==0)AlphaBarIndex=0;//-------------------------图片循环
    setTimeout("AlphaBar()",4000);//------------------变换间隔时间
    }
    </SCRIPT>


    <A id=AlphaBarLinkHref href="">
    <IMG id=imgObj height=100 src="images/1.jpg" width=568 galleryImg="no">
    </A>
    <IMG id=imgSwapObj height=0 src="" width=0>


    </BODY>
     
  6. 小叶

    小叶 New Member

    注册:
    2005-09-04
    帖子:
    17,941
    赞:
    33
    我以前有一个,过几天翻翻,,
     
  7. 小白

    小白 New Member

    注册:
    2005-09-25
    帖子:
    1,604
    赞:
    9
    谢谢~~~~
    测试下:)