2017-06-06 68 views
0

我的網站上,我有兩個的fancybox實例防止從開放第二的fancybox當其他的fancybox實例已經打開

  1. 打開YouTube視頻時,有人點擊的div
  2. 開放的通訊彈出25秒鐘之後,當有人訪問網站。

問題是,當有人點擊div並開始觀看視頻,如果25秒內通過,它將打開新聞通訊彈出窗口並關閉已打開的視頻彈出窗口。這會給網站用戶帶來不好的體驗嗎?

以下是雙方的fancybox實例的代碼

視頻彈出的jQuery

jQuery("#yblock").click(function() { 
jQuery.fancybox({ 
     'padding'  : 0, 
     'aspectRatio'   : true, 
     'transitionIn' : 'none', 
     'transitionOut' : 'none', 
     'title'   : this.title, 
     'width'  : 780, 
     'height'  : 500, 
     'href'   : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'), 
     'type'   : 'swf', 
     'swf'     : { 
      'wmode'  : 'transparent', 
      'allowfullscreen' : 'true' 
     }, 
     helpers     : { 
      'overlay': { 
      'locked': false 
         } 
     } 

通訊彈出的jQuery

jQuery(function ($) { 
setTimeout(function() { 
       beginNewsletterForm(); 
      }, 25000); 
}); 

function beginNewsletterForm() { 
    jQuery.fancybox({ 
     'padding': '0px', 
     'autoScale': true, 
     'transitionIn': 'fade', 
     'transitionOut': 'fade', 
     'type': 'inline', 
     'href': '#newsletter_popup', 
     'onComplete': function() { 
      $.cookie('newsletter_popup', 'shown'); 
     }, 
     'tpl': { 
      closeBtn: '<a title="Close" class="fancybox-item fancybox-close fancybox-newsletter-close" href="javascript:;"></a>' 
     }, 
     'helpers': { 
      overlay: { 
       locked: true 
      } 
     } 
    }); 
    jQuery('#newsletter_popup').trigger('click'); 
} 

我想阻止第二的fancybox打開,如果第一個的fancybox已經打開

回答

1

對不起,我以前的英語。對於使用同一個插件(fancybox)一次打開2模式可能會導致衝突。您可以嘗試用fancybox打開視頻框,然後使用bootstrap modal或其他插件打開簡報框。可能會有所幫助。謝謝