简单的JavaScript图像旋转器 [英] Simple JavaScript image rotator

查看:114
本文介绍了简单的JavaScript图像旋转器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个网站上有一个简单的图像旋转器,由4个图像组成,在显示下一个图像之前必须出现几秒钟。它似乎在第一个周期工作,但是当它回到第一个图像时,它不会显示那个图像,但会从第二个图像再次运行,等等,每个周期都会丢失该图像。
函数在主体中使用onLoad EH调用。在身体里面有一张img,里面有我的第一张图片。我是一个noob,所以如果我错过了任何东西,请保持温柔。
这是我的...

 < body onLoad =sunSlideShow()> 

< img src =IMAGES / slider1.gifalt =slide-showid =mySliderwidth =900>

< body>




var quotes = new Array(slider2.gif,slider3.gif,slider4.gif,slider1.gif) ;

var i = 0


函数sunSlideShow()
{
document.getElementById(mySlider)。src =( IMAGES /+引号[i]);

if(i <4)
{
i ++;
}

else

i = 1;

setTimeout(sunSlideShow(),3000);

$ b sunSlideShow()


解决方案改变它为:



else
i = 0;
setTimeout(sunSlideShow(),3000);


I have a simple image rotator on a website consisting of 4 images that have to appear for a few seconds before showing the next one. It seems to work on its first cycle but then when it gets back to the first image it doesn't show that one but works again from the second image and so on always missing that image on every cycle. The function is called using onLoad EH in the body. In the body there is an img with my first image inside it. I'm a noob so please be gentle if I've missed anything out. Here's what I have...

<body onLoad="sunSlideShow()">

    <img src="IMAGES/slider1.gif" alt="slide-show" id="mySlider" width="900">

<body>




var quotes = new Array ("slider2.gif", "slider3.gif" ,"slider4.gif", "slider1.gif");

var i = 0


function sunSlideShow()
{
    document.getElementById("mySlider").src = ( "IMAGES/" + quotes[i] );

    if (i<4)
    {
        i++;
    }

    else

        i = 1;

    setTimeout("sunSlideShow()", 3000);

}
sunSlideShow()

解决方案

Change it to this:

else i = 0; setTimeout("sunSlideShow()", 3000);

这篇关于简单的JavaScript图像旋转器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆