JQuery幻灯片:Firefox v.13.0.1

时间:2012-06-28 07:30:30

标签: javascript jquery slideshow

我在幻灯片库中使用以下脚本,它应该每隔10秒一个接一个地旋转几个图片。

直到我将Firefox升级到版本13.0.1之前,它一直工作(在FF中)。

此刻,如果它运行了一段时间,那么它就搞砸了 - 它忽略了计时器,只旋转了2个图片,完全忽略了其他3个。

如何解决此问题并使脚本更健壮?

谢谢!!!

function slideSwitch() {
    var $active = $('#slideshow div.active');

    if ( $active.length == 0 ) $active = $('#slideshow div:last');

    //  pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next() : $('#slideshow div:first');
    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 3000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    var timer = setInterval( "slideSwitch()", 10000 );

        $('#slideshow').hover(
                function () {
                    clearInterval(timer);   
                },  
                function () {
                    timer = setInterval("slideSwitch()", 10000);            
                }
        ); 

});

我通过以下方式在html中调用jquery:

                    <div id="slideshow">
                        <div class="active">
                            <img src="/images/slideImages/1.jpg" alt="xxx 1" title = "xx 1"/>
                        </div>
                        <div>
                            <img src="/images/slideImages/2.jpg" alt="xxx 2" title="xx 2" />
                        </div>
                        <div>
                            <img src="/images/slideImages/3.jpg"  alt="xxx 3" title="xx 3" />
                        </div>
                        <div>
                            <img src="/images/slideImages/4.jpg"  alt="xx 4" title="xx 4"  />
                        </div>
                        <div>
                            <img src="/images/slideImages/5.jpg"  alt="xxx 5" title="xx 5"  />
                        </div>
                    </div>

1 个答案:

答案 0 :(得分:0)

确保您的代码类型为“javascript”

Firefox不理解“jscript”就像chrome和safari一样