开发者

jQuery image fader slow in IE6 & 7

I'm using the following jQuery script to rotate through a series of images pulled into an unordered list using PHP:

function theRotator() {
    $('#rotator li').css({opacity: 0.0});
    $('#rotator li:first').css({opacity: 1.0});
    setInterval('rotate()',5000);
};

function rotate() { 
    var current = ($('#rotator li.show') ?  $('#rotator li.show') : $('#rotator li:first'));
    var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('#rotator li:first') :current.next()) : $('#rotator li:first'));开发者_如何学C   
    next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 2000);
    current.animate({opacity: 0.0}, 2000).removeClass('show');
};

$(document).ready(function() {      
    theRotator();
});

It works brilliantly in FF, Safari, Chrome and even IE8 but IE6 & 7 are really slow. Can anyone make any suggestions on making it more efficient or just work better in IE6 & 7?

The script is from here btw. Thanks.


Hey Jamie, Just remember that IE6+7 don't use the same Javascript parsers as real browsers (It's a joke!) FF Chrome & Safari all have prioritized faster javascript execution in recent versions, whereas IE may show performance in IE9 (I hope they do myself.) Also realize this slideshow will run slow in mobile devices, etc. It's not that you're doing anything wrong persay, just that JS is handled differently in different places.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜