JQuery 幻灯片:火狐 v.13.0.1

JQuery slideshow : Firefox v.13.0.1

本文关键字:火狐 幻灯片 JQuery      更新时间:2023-09-26

我正在使用以下脚本进行幻灯片库,它应该每 10 秒一个接一个地旋转几张照片。

它一直有效(在FF中),直到我将Firefox升级到版本13.0.1。

目前,如果它运行一段时间,那么它就会搞砸 - 它忽略计时器,只旋转 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>

请确保您的标签类型为"javascript"

Firefox不像chrome和safari那样理解"jscript"