Jquery Cycle + Jcarousel幻灯片大拇指没有加载?

时间:2010-08-18 17:58:04

标签: jquery jcarousel jquery-cycle

我正在组合jquery循环和jcarousel来制作幻灯片。它在Firefox,Chrome和Safari中运行良好,但在IE中缩略图未加载。

我猜它与如何生成寻呼机中的图像有关,然后jcarousel只是不能在IE中处理,但我不确定。我觉得我非常接近让幻灯片显示工作,但我需要弄清楚它为什么在IE中失败。

这是html代码:

<!-- PHOTO SLIDESHOW CONTROLS -->                   
    <div id="photo-slideshow-controls">

        <a id="prev-btn" href="#">Prev</a> 
        <a id="next-btn" href="#">Next</a>
        <a id="play" href="#">Play</a> 
        <a id="pause" href="#">Pause</a>

        <div class="clear"></div>

    </div><!--/PHOTO SLIDESHOW CONTROLS -->


    <!-- PHOTO SLIDESHOW -->
    <div id="advanced-slideshow">
        <img src="assets/bridge-towers.jpg" width="593" height="474" alt="Bridge Towers" name="John Doe" />
        <img src="assets/dixie-lan-bbq.jpg" width="632" height="474" alt="BBQ" name="Jane Doe l Associated Press" />
        <img src="assets/downtown-overlook.jpg" width="632" height="421" alt="Overlooking Downtown Kansas City" name="Joel Johns l GardnerEDGE" />
        <img src="assets/downtown-skyline.jpg" width="474" height="219" alt="Downtown Kansas City Skyline" name="Brett Jankord" />
        <img src="assets/liberty-tower.jpg" width="356" height="474" alt="Liberty Tower" name="Steve Hengeli" />
        <img src="assets/plaza-fountain.jpg" width="632" height="468" alt="Plaza Fountain" name="Kevin Wright l GardnerEDGE" />
        <img src="assets/sprint-center.jpg" width="632" height="371" alt="Sprint Center" name="John Doe" />
        <img src="assets/union-station.jpg" width="632" height="416" alt="Union Station at night" name="Jane Doe" />
        <img src="assets/western-auto.jpg" width="632" height="474" alt="Western Auto" name="Kevin Wright l GardnerEDGE" />
        <img src="assets/bridge-towers.jpg" width="593" height="474" alt="Bridge Towers" name="John Doe" />
        <img src="assets/dixie-lan-bbq.jpg" width="632" height="474" alt="BBQ" name="Jane Doe l Associated Press" />
        <img src="assets/downtown-overlook.jpg" width="632" height="421" alt="Overlooking Downtown Kansas City" name="Joel Johns l GardnerEDGE" />
        <img src="assets/downtown-skyline.jpg" width="474" height="219" alt="Downtown Kansas City Skyline" name="Brett Jankord" />
    </div><!--/PHOTO SLIDESHOW -->


    <div id="photo-credit"></div>


    <ul id="mycarousel" class="jcarousel-skin-tango">
    </ul>

    <div class="clear"></div>


    <div id="slideshow-caption"></div> 

所以循环滑动了div#advanced-slideshow中的imgs,然后根据ul#mycarousel中的那些图像创建了一个缩略图分页器。然后jcarousel使用ul#mycarousel中的列表项来构建轮播。就像FF,Chrome,Safari中的魅力一样,但我无法弄清楚如何让它在IE中运行。

这是JS代码:

$(document).ready(function(){

// Adds ability to link to specifics slides    
var index = 0, hash = window.location.hash;
if (hash) {
    index = /\d+/.exec(hash)[0];
    index = (parseInt(index) || 1) - 1; // slides are zero-based
}

// Setup for Cycle Plugin
$('#advanced-slideshow').cycle({ 
prev:   '#prev-btn', 
next:   '#next-btn', 
timeout: 0, 
before: onBefore,
startingSlide: index,
pager:  '#mycarousel', 
    // callback fn that creates a thumbnail to use as pager anchor 
    pagerAnchorBuilder: function(idx, slide) { 
        return '<li><a href="#"><img src="' + slide.src + '" width="75" height="75" /></a></li>'; 
    } 
}); 



//Pauses slideshow
$('#pause').click(function() { $('#photo-slideshow').cycle('pause'); return false; });

//Instantly resumes slidesshow
$('#play').click(function() { $('#photo-slideshow').cycle('resume', true); });


/* Delayed resumes slideshow
$('#play').click(function() { $('#photo-slideshow').cycle('resume'); return false; });
*/




function onBefore(curr,next,opts) {


    // Centers the image
    var $slide = $(next);
    var w = $slide.outerWidth();
    var h = $slide.outerHeight();
    $slide.css({
        marginTop: (476 - h) / 2,
        marginLeft: (634 - w) / 2
    });


    // Centers the DIV vertically!!!!   
    var divHeight = 476;
    var theImageHeight = $slide.outerHeight();
    var newTopMargin = (divHeight - theImageHeight) / 2;
    if(theImageHeight > 476){
        $('#advanced-slideshow').css({
            marginTop: newTopMargin
        });
    }


    // Adds caption and credit line
    $('#photo-credit').html('<p>' + "Photo By: "  + this.name + '</p>') 

    $('#slideshow-caption').html(this.alt); 


    // Adds ability to link to certain slides
    {window.location.hash = opts.currSlide + 1;}


};


//jCarousel 
$('#mycarousel').jcarousel({
    scroll: 5,
    visible: 5,
});

}); //结束

这是我到目前为止的链接。 Demo

对此的任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

在jquery论坛上的用户指出我有一个额外的, 我需要改变visbile:5,可见:5

效果很好,现在幻灯片可以在IE中运行。我通过IE 8测试了IE 6。如果你的JS代码在head标签中而不是在页面的末尾,它往往在IE中工作得更好。我想我会分享这个以防其他人想要使用它。