Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 要将自动播放设置添加到响应图像库。_Javascript_Jquery_Html_Slider - Fatal编程技术网

Javascript 要将自动播放设置添加到响应图像库。

Javascript 要将自动播放设置添加到响应图像库。,javascript,jquery,html,slider,Javascript,Jquery,Html,Slider,我已将此图像库添加到我正在处理的网站。完美无瑕,唯一的问题是没有自动播放幻灯片的选项 任何帮助都将不胜感激 您想创建一个新按钮,触发setInterval函数循环浏览幻灯片。它看起来是这样的: <button onclick="play()">slideshow</button> function play() { setInterval(function() { // Do the code that triggers next image

我已将此图像库添加到我正在处理的网站。完美无瑕,唯一的问题是没有自动播放幻灯片的选项


任何帮助都将不胜感激

您想创建一个新按钮,触发setInterval函数循环浏览幻灯片。它看起来是这样的:

<button onclick="play()">slideshow</button>

function play() {
    setInterval(function() {
       // Do the code that triggers next image
    }, 1000);
}

数字1000是正在运行的函数之间的毫秒。

您想创建一个新按钮,触发setInterval函数在幻灯片中循环。它看起来是这样的:

<button onclick="play()">slideshow</button>

function play() {
    setInterval(function() {
       // Do the code that triggers next image
    }, 1000);
}
数字1000是正在运行的函数之间的毫秒数。

试试这个

var current=1;
    function autoAdv()
    {
        if(current==-1) return false;

        $('.es-carousel a').eq(current%$('.es-carousel a').length).trigger('click',[true]);    // [true] will be passed as the contentScroll parameter of the click function
        current++;
        $('.rg-image-nav-prev').eq(current%$('.rg-image-nav-prev').length).trigger('click',[true]);    // [true] will be passed as the contentScroll parameter of the click function
        current++;
    }

    // The number of seconds that the slider will auto-advance in:

    var changeEvery = 10;

    var itvl = setInterval(function(){autoAdv()},changeEvery*1000);​
试试这个

var current=1;
    function autoAdv()
    {
        if(current==-1) return false;

        $('.es-carousel a').eq(current%$('.es-carousel a').length).trigger('click',[true]);    // [true] will be passed as the contentScroll parameter of the click function
        current++;
        $('.rg-image-nav-prev').eq(current%$('.rg-image-nav-prev').length).trigger('click',[true]);    // [true] will be passed as the contentScroll parameter of the click function
        current++;
    }

    // The number of seconds that the slider will auto-advance in:

    var changeEvery = 10;

    var itvl = setInterval(function(){autoAdv()},changeEvery*1000);​

我到处拼凑,想出了一个办法,谢谢你的帮助

var t;
var timer_is_on=0;

function timedCount()
{
$('.rg-image-nav-next').click()
t=setTimeout("timedCount()",1000);
}

function doTimer()
{
if (!timer_is_on)
{
timer_is_on=1;
timedCount(1000);
}
}

function stopCount()
{
clearTimeout(t);
timer_is_on=0;
} 
timeCount功能每1秒激活下一个图像。doTimer功能可防止计时器被多次激活。stopCount功能允许暂停幻灯片放映

然后,我添加了两个暂停和播放按钮:

<div class="playbutton"><a href="javascript:doTimer();"><img src="images/play.png" width="24" height="24" alt="Play"></a></div>
<div class="pausebutton"><a href="javascript:stopCount();"><img src="images/pause.png" width="24" height="24" alt="Pause"></a></div>

你可以看到它在这里工作:

我在这里和那里拼凑了一点一点的东西,并想出了一个方法,谢谢你的帮助

var t;
var timer_is_on=0;

function timedCount()
{
$('.rg-image-nav-next').click()
t=setTimeout("timedCount()",1000);
}

function doTimer()
{
if (!timer_is_on)
{
timer_is_on=1;
timedCount(1000);
}
}

function stopCount()
{
clearTimeout(t);
timer_is_on=0;
} 
timeCount功能每1秒激活下一个图像。doTimer功能可防止计时器被多次激活。stopCount功能允许暂停幻灯片放映

然后,我添加了两个暂停和播放按钮:

<div class="playbutton"><a href="javascript:doTimer();"><img src="images/play.png" width="24" height="24" alt="Play"></a></div>
<div class="pausebutton"><a href="javascript:stopCount();"><img src="images/pause.png" width="24" height="24" alt="Pause"></a></div>

您可以看到它在这里工作:

嘿,谢谢您的快速回复。因为我是一个完全的javascript初学者,我会把它放在.js文件中的什么位置,假设它会放在gallery.js文件中。我把它粘贴在这里:在gallery.js中添加了它,但它实际上阻止了缩略图旋转木马和gallery的工作。谢谢你对我的宽容和帮助!嘿,谢谢你的快速回复。因为我是一个完全的javascript初学者,我会把它放在.js文件中的什么位置,假设它会放在gallery.js文件中。我把它粘贴在这里:在gallery.js中添加了它,但它实际上阻止了缩略图旋转木马和gallery的工作。谢谢你对我的宽容和帮助!