2012-06-28 59 views
0

我对幻灯片库使用以下脚本,它应该每10秒钟一个接一个地旋转几张图片。JQuery幻灯片:Firefox v.13.0.1

它工作(在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);    
       } 
     ); 

}); 

我打电话通过jquery的以html:

    <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> 

回答

0

确保您的标签类型是 “JavaScript的”

Firefox不明白 “的JScript” 像Chrome和Safari做

+0

虽然字符集是“utf-8 without BOM”,但它已经是“Javascript”了。我想知道这是否是问题。仅将其更改为“utf8”。谢谢。 – Veni

+0

在您更改后是否有效? –