第一次使用Chrome时,jQuery幻灯片不会加载。在Firefox上

时间:2013-03-30 12:41:40

标签: jquery google-chrome slideshow

我是这个论坛的新手。我的代码似乎有问题。

  • 首次加载页面时,幻灯片显示丢失。
  • 当我点击刷新时,它不会回来。
  • 获得它的唯一方法是再次点击菜单栏中的页面链接。

我非常感谢您的帮助:)我是新手,希望以下代码足够:

    if(!Date.prototype.toISOString) 
    {
    Date.prototype.toISOString = function() 
{
    function pad(n) {return n < 10 ? '0' + n : n}
    return this.getUTCFullYear() + '-'
        + pad(this.getUTCMonth() + 1) + '-'
            + pad(this.getUTCDate()) + 'T'
                + pad(this.getUTCHours()) + ':'
                    + pad(this.getUTCMinutes()) + ':'
                        + pad(this.getUTCSeconds()) + 'Z';
};
 }
function onAfterSlide(prevSlide, currentSlide)
{
var expando = $(this).get(0)[jQuery.expando];
$("#slider_navigation_" + expando + " .slider_control").addClass("inactive");
$("#" + $(currentSlide).attr("id") + "_content").fadeIn(200, function(){
    $("#slider_navigation_" + expando + " .slider_control").removeClass("inactive");
}); 
   }
  function onBeforeSlide(prevSlide, currentSlide)
  {
var expando = $(this).get(0)[jQuery.expando];
$(".slider_" + expando + "_content_container .slider_content").fadeOut(200);
var position = $($("#" + $(currentSlide).attr("id") + "_control")).position();
var positionPrev = $($("#" + $(prevSlide).attr("id") + "_control")).position();
$("#slider_navigation_" + expando + " .slider_control_bar").css("display", "none");
$("#slider_navigation_" + expando + " .slider_bar").css({
    "display": "block",
    "margin-left": positionPrev.left + "px"
});
$("#slider_navigation_" + expando + " .slider_bar").animate({
    'margin-left': position.left + "px"
}, 750, "easeInOutQuint", function(){
    $(this).css("display", "none");
    $("#" + $(currentSlide).attr("id") + "_control").children("#slider_navigation_" + expando + " .slider_control_bar").css("display", "block");
});
 }
    var map = null;
   jQuery(document).ready(function($){
//mobile menu
$(".mobile_menu select").change(function(){
    window.location.href = $(this).val();
    return;
});

//slider
$(".slider").carouFredSel({
    responsive: true,
    prev: {
        onAfter: onAfterSlide,
        onBefore: onBeforeSlide,
        easing: "easeInOutQuint",
        duration: 750
    },
    next: {
        onAfter: onAfterSlide,
        onBefore: onBeforeSlide,
        easing: "easeInOutQuint",
        duration: 750
    },
    auto: {
        play: true,
        pauseDuration: 5000,
        onAfter: onAfterSlide,
        onBefore: onBeforeSlide,
        easing: "easeInOutQuint",
        duration: 750
    }
},
{
    wrapper: {
        classname: "caroufredsel_wrapper caroufredsel_wrapper_slider"
    }
});
$(".slider").sliderControl({
    appendTo: $(".slider_content_box"),
    contentContainer: $(".slider_content_box")
});

//image carousel
$(".image_carousel").carouFredSel({
    responsive: true,
    prev: {
        onAfter: onAfterSlide,
        onBefore: onBeforeSlide,
        easing: "easeInOutQuint",
        duration: 750
    },
    next: {
        onAfter: onAfterSlide,
        onBefore: onBeforeSlide,
        easing: "easeInOutQuint",
        duration: 750
    },
    auto: {
        play: false,
        pauseDuration: 5000,
        onAfter: onAfterSlide,
        onBefore: onBeforeSlide,
        easing: "easeInOutQuint",
        duration: 750
    }
});
$(".image_carousel").sliderControl({
    appendTo: "",
    contentContainer: ""
});

/*$("ul.gallery_item_details_list").css({
    "height": 0,
    "display": "none"
});
$(".gallery_item_details_list li.gallery_item_details").css("display", "none");*/

//horizontal carousel
$(".horizontal_carousel").carouFredSel({
    items: {
        visible: 4
    },
    scroll: {
        items: 1,
        easing: "swing",
        pauseOnHover: true
    },
    auto: {
        play: false,
        items: 1
    }
});
$(".our_clinic").trigger("configuration", {
    prev: '#our_clinic_prev',
    next: '#our_clinic_next'
});
$(".carousel").trigger("configuration", {
    prev: '#carousel_prev',
    next: '#carousel_next'
});
setTimeout(function(){
    $(".testimonials").trigger("configuration", {
        items: {
            visible: 2
        },
        prev: '#testimonials_prev',
        next: '#testimonials_next'
    });
}, 1000);

//training_classes
$(".accordion").accordion({
    event: 'change',
    autoHeight: false
});
$(".accordion.wide").bind("accordionchange", function(event, ui){
    $("html, body").animate({scrollTop: $("#"+$(ui.newHeader).attr("id")).offset().top}, 400);
});
$(".tabs").bind("tabsbeforeactivate", function(event, ui){
    $("html, body").animate({scrollTop: $("#"+$(ui.newTab).children("a").attr("id")).offset().top}, 400);
});
$(".tabs").tabs({
    event: 'change',
    show: true,
    create: function(){
        $("html, body").scrollTop(0);
    }
});

//image controls
var currentControls;
$(".gallery_box").hover(function(){
    var width = $(this).find("img").first().width();
    var height = $(this).find("img").first().height();
    currentControls = $(this).find(".controls");
    var currentControlsWidth = currentControls.outerWidth();
    var currentControlsHeight = currentControls.outerHeight();
    if(!currentControls.hasClass("hovered"))
    {
        currentControls.addClass("hovered");
        currentControls.css({
            "display": "block",
            "margin-left": (width/2-currentControlsWidth/2) + "px",
            "top": (height) + "px"
        });
        currentControls.animate({"top": (height/2-currentControlsHeight/2) + "px"},250,'easeInOutCubic');
    }

},function(){
    if(currentControls.hasClass("hovered"))
    {
        currentControls.css("display", "block");
        var height = $(this).find("img").first().height();
        currentControls.animate({"top": (height) + "px"},250,'easeInOutCubic', function(){
            $(this).css("display","none");
            $(this).removeClass("hovered");
        });
    }
});

//browser history
$(".tabs .ui-tabs-nav a").click(function(){
    if($(this).attr("href").substr(0,4)!="http")
        $.bbq.pushState($(this).attr("href"));
    else
        window.location.href = $(this).attr("href");
});
$(".ui-accordion .ui-accordion-header").click(function(){
    $.bbq.pushState("#" + $(this).attr("id").replace("accordion-", ""));
});

//tabs box navigation
$(".tabs_box_navigation").mouseover(function(){
    $(this).find("ul").removeClass("tabs_box_navigation_hidden");
});
$(".tabs_box_navigation a").click(function(){
    $(".tabs_box_navigation_selected .selected").removeClass("selected");
    $(this).parent().addClass("selected");
    $(this).parent().parent().parent().children('span').text($(this).text());
    $(this).parent().parent().addClass("tabs_box_navigation_hidden");
});
$(".contact_form .tabs_box_navigation a").click(function(event){
    event.preventDefault();
    $(this).parent().parent().parent().children("[type='hidden']").first().val($.trim($(this).text()));
});

0 个答案:

没有答案