2015-10-31 32 views
0

[注:我不是編程高手。]/嘗試了很多:無法添加彈出顯示延遲

我想了很多,搜索這個平臺,但沒有找到任何解決辦法。

我需要在顯示一個彈出框中添加30秒延遲。我採取了腳本from here。腳本已經淡出時間,並且工作正常。

檢查下面的腳本......我用'delay()'替換'close()'。它不工作。

<script type="text/javascript"> 

$(document).ready(function() { 
    if($.cookie('the_cookie') != 1) { // If the_cookie not set to 1 then initializes and play calling the popup 
     $.cookie('the_cookie', '1', { expires: 1 }); // Value day (s) before expiration of the cookie 

     $.fancybox(
      $("#popup").html(), 
      { 
       type : 'iframe', 
       href : '/contact.php', // url vers notre page html qui sera charg?e dans la popup en mode iframe 
       maxWidth : 415, 
       maxHeight : 475, 
       fitToView : false, 
       width : '90%', 
       height : '95%', 
       autoSize : false 

     } 
     );setTimeout(function(){ $.fancybox.delay(30000) },10000); 



    } 
}); 

+0

任何人都可以幫我找到解決辦法嗎? –

+0

所以你想彈出關閉30秒後正確的。 – Hashy

+0

@Hashy我想在30秒後顯示彈出窗口。 –

回答

2

嘗試下面的代碼,

$(document).ready(function() { 
     if($.cookie('the_cookie') != 1) { // Si the_cookie n'a pas pour valeur 1 alors on l'initialise et on joue l'appel de la popup 
      $.cookie('the_cookie', '1', { expires: 1 }); // valeur en jour avant expiration du cookie 

     //below 3000 is 3 sec delay then popup appears. 
      setTimeout(fire, 3000); 
     //below 5000 is 5 sec dely after that popup closes. 
      setTimeout("parent.$.fancybox.close()", 5000); 
     } 
    }); 

    function fire() { 
    $.fancybox(
       $("#popup").html(), 
       { 
        type : 'iframe', 
        href : 'http://www.site-web-creation.net/source/pub.html', // url vers notre page html qui sera chargée dans la popup en mode iframe 
        maxWidth : 800, 
        maxHeight : 300, 
        fitToView : false, 
        width : '70%', 
        height : '70%', 
        autoSize : false 

      } 
      ); 

    } 

我希望這有助於清除你的問題。根據您對延誤的需求而改變。我只是設置計時器來觸發一個事件,在這種情況下彈出框使用函數fire。

+0

像一個魅力工作。非常感謝。它只是按我想要的方式工作。 –