2010-11-17 32 views
1

我有一個FancyBox設置在我的網站上,但它在PageLoad上打開,而不是我想要的,這是它通過點擊觸發的。我是一個jQuery和JavaScript等總新手,所以在這裏忍受我。以下是我已經設置代碼:` 取消FancyBox on PageLoad

 $(document).ready(function() { 
      $(".iframe").fancybox({ 
      'transitionIn' : 'elastic', 
      'transitionOut' : 'elastic', 
      'speedIn' : 600, 
      'speedOut' : 200, 
      'overlayShow' : true, 
      'autoScale' : true, 
      'width'  : '50%', 
      'height' : '90%', 
      'overlayOpacity': 0.8, 
      'centerOnScroll': true, 
      'showCloseButton': true 

      }); 


      $(".iframe").trigger('click'); 
     }); 

`

+0

什麼是頁面的html(沒有內容),或者至少是iframe元素。 – 2010-11-17 22:02:53

回答

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

    $(".iframe").fancybox({ 
    'transitionIn' : 'elastic', 
    'transitionOut' : 'elastic', 
    'speedIn' : 600, 
    'speedOut' : 200, 
    'overlayShow' : true, 
    'autoScale' : true, 
    'width'  : '50%', 
    'height' : '90%', 
    'overlayOpacity': 0.8, 
    'centerOnScroll': true, 
    'showCloseButton': true 

    }); 

    $('a.trigger').click(function(e) { 
    e.preventDefault(); 
    $(".iframe").trigger('click'); 
    }); 
}); 
1

代碼

$(".iframe").trigger('click'); 

導致生成一個 'click' 事件負載,只是刪除該行。

+0

這是正確的,雖然它可能看起來像它代表「觸發當我點擊」,它代表「模擬點擊這個元素」 – 2010-11-17 22:04:41

+0

神奇,你們都搖滾我的襪子! – 2010-11-18 01:31:03