2013-03-06 153 views
0

我正在使用全屏幕背景jquery滑塊的網站,這是默認在暫停狀態。自動播放全屏背景滑塊

我試着玩jQuery,但它並沒有爲我工作。

我還試圖用觸發方式頁面加載

$(window).bind("load", function() { 
    $('a#play, a.play').trigger('click'); 
}); 

後覆蓋由點擊「播放」按鈕,當前的暫停狀態,但沒有工作太...

我米粘貼低於該jQuery腳本可能確實的動作

jQuery(document).ready(function($){ 

$('body').append('<span id="body_loader"></span>'); 
    $('#body_loader').fadeIn(); 

//In our jQuery function, we will first cache some element and define some variables: 
var $bg    = $('#background'), 
    $bg_img   = $bg.find('img'), 
    $bg_img_eq  = $bg_img.eq(0), 
    total   = $bg_img.length, 
    current   = 0, 
    $next  = $('#next'), 
    $prev  = $('#prev') 

$(window).load(function(){ 
    //hide loader 
    $('#body_loader').fadeOut('fast', function(){ 
     init(); 
    }).remove(); 

}); 

var intervalID, 
    play = $('#play'), 
    titleItem = $('.title-item'); 

//shows the first image and initializes events 
function init(){ 
    //get dimentions for the image, based on the windows size 
    var dim = getImageDim($bg_img_eq); 
    //set the returned values and show the image 
    $bg_img_eq.css({ 
     width : dim.width, 
     height : dim.height, 
     left : dim.left, 
     top : dim.top 
    }).fadeIn('normal'); 

    //resizing the window resizes the $tf_bg_img 
    $(window).bind('resize',function(){ 
     var dim = getImageDim($bg_img_eq); 
     $bg_img_eq.css({ 
      width : dim.width, 
      height : dim.height, 
      left : dim.left, 
      top  : dim.top 
     }); 
    }); 

    var activeTitle = $bg_img_eq.attr('title'); 
     titleItem.html(activeTitle); 
     titleItem.html(function(){ 
      var text= $(this).text().split(" "); 
      var last = text.pop(); 
      return text.join(" ")+ (text.length > 0 ? " <span class='word-last'>"+ last + "</span>" : last); 
     }); 

    play.bind('click', function() { 
     if($(this).hasClass('pause')) { 
      clearInterval(intervalID); 
      $(this).removeClass('pause').addClass('play'); 
     } else { 
      $(this).addClass('pause').removeClass('play'); 
      intervalID = setInterval("$('#next').trigger('click')", 10000); 
     } 

    }); 

    //click the arrow down, scrolls down 
    $next.bind('click',function(){ 
     if($bg_img_eq.is(':animated')) 
      return false; 
      scroll('tb'); 
    }); 

    //click the arrow up, scrolls up 
    $prev.bind('click',function(){ 
     if($bg_img_eq.is(':animated')) 
     return false; 
     scroll('bt'); 
    }); 
} 

DIV保持該圖像的類& ID是background和PL ay按鈕類和id是play

或許我會http://xhtml.webtemplatemasters.com/style/dark/index.html#

回答

1

在general.js文件

play.trigger('click'); 

添加這一點,如果它是WordPress模板,然後

if(slide_autostart){ 
play.trigger('click'); 
}