簡體   English   中英

jQuery Cycle插件IE6 / 7問題

[英]jQuery Cycle plugin IE6/7 issues

我已經使用Cycle插件實現了幻燈片演示,該插件可在除IE6&7之外的所有瀏覽器中使用,IE6&7的圖像僅顯示在列表中,並且#page_copy div沒有隱藏。 我整天都在瀏覽代碼,沒有任何運氣,也不完全確定我應該尋找的方式或內容。

調試此問題的最佳方法是什么? 我知道在刪除其余代碼后,#page_copy div隱藏了,並且我嘗試了反向操作(沒有結果)

<script type="text/javascript" charset="utf-8">
        jQuery.fn.fadeToggle = function(speed, easing, callback) { 
            return this.animate({opacity: 'toggle'}, speed, easing, callback); 
        };


        $(document).ready(function() {
            $('#page_copy').hide();
            $('a#info_close_button').click(function() {
                $('#page_copy').fadeOut(200);
                return false;
            });
            $('a#info_button').click(function() {
                $('#page_copy').fadeToggle(200);
                return false;
            });
        });


        $(window).load(function() {
            // vertically center single image
            var $image_cnt = $("#images > img").size();
            if($image_cnt < 2) {
                var $single_img = $("#images").children(':first-child');
                var h = $single_img.height();
                $single_img.css({
                    marginTop: (620 - h) / 2,
                });
                $(".next").css("display","none");
                $(".prev").css("display","none");
            }
        });


        // wait until images have loaded before starting cycle
        $(window).load(function() {
            // front image rotator
            $('#images').cycle({ 
                fx: 'fade',
                speed:  300, 
                next:   '.next', 
                prev:   '.prev',
                containerResize: 0,
                timeout:  0, 
                delay:   -2000,
                before: onBefore
            });

        }); 

        // hide all but the first image when page loads
        $(document).ready(function() {
            $('#images img:gt(0)').hide();
        });

        // callback fired when each slide transition begins
        function onBefore(curr,next,opts) {
            var $slide = $(next);
            var w = $slide.width();
            var h = $slide.height();
            $slide.css({
                marginTop: (620 - h) / 2,
                marginLeft: (650 - w) / 2
            });
        };
    </script>

我真的不明白為什么你有多個$(document).ready$(window).load ..

也許您應該嘗試將所有內容放在單個$(document).ready塊中。

另外,在<script>標記的開頭移動function onBefore(...)的定義。 直接在jQuery.fn.fadeToggle代碼之前。

嘗試在這段代碼的結尾處也刪除不需要的逗號

$single_img.css({
    marginTop: (620 - h) / 2, //<---- remove comma
});

並刪除不需要的分號

function onBefore(curr,next,opts) {...}; //<--- unneeded

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM