2015-10-18 99 views
0

我正在使用以下腳本在客戶端頁面上顯示彈出窗口。她要求延遲60秒。我正在使用setTimeout,但我在實施時遇到問題。據延遲#mask,但不#boxes #dialog延遲彈出60秒

你可以在這裏查看網站:http://www.julialucille.com/

任何幫助,將不勝感激,謝謝! 這是我的腳本。

$(document).ready(function() { 

    setTimeout(function(){ 
     var id = '#dialog'; 

     //Get the screen height and width 
     var maskHeight = $(document).height(); 
     var maskWidth = $(window).width(); 

     //Set height and width to mask to fill up the whole screen 
     $('#mask').css({'width':maskWidth,'height':maskHeight}); 

     //transition effect  

     $('#mask').fadeTo("slow",0.3); 
     $('#boxes #dialog').fadeTo("slow"); 

    }, 60000); 

    //if close button is clicked 
    $('.window .close').click(function (e) { 

     //Cancel the link behavior 
     e.preventDefault(); 
     $('#mask').hide(); 
     $('.window').hide(); 
    }); 

    //if mask is clicked 
    $('#mask').click(function() { 
     $(this).hide(); 
     $('.window').hide(); 
    }); 

}); 
+1

除了使用setTimeout ...請,請_please_強烈建議您的客戶不要這樣做。作爲一名網站用戶,讓這些令人討厭的「註冊我的通訊」彈出窗口突然出現,尤其是當他們完全接管你正在做的事情時,真是令人憤怒。 –

回答

0

確保雙方#mask#dialog都被設置爲在CSS display: none;,然後根據下面的腳本

$(document).ready(function() { \t 
 

 
    setTimeout(function(){ 
 
    var id = '#dialog'; 
 

 
    //Get the screen height and width 
 
    var maskHeight = $(document).height(); 
 
    var maskWidth = $(window).width(); 
 

 
    //Set heigth and width to mask to fill up the whole screen 
 
    $('#mask').css({'width':maskWidth,'height':maskHeight}); 
 

 
    //transition effect \t \t 
 

 
    $('#mask').fadeTo("slow",0.3); 
 
    $(id).fadeTo("slow", 1); 
 

 
    }, 30000); 
 

 
    //if close button is clicked 
 
    $('.window .close').click(function (e) { 
 
    //Cancel the link behavior 
 
    e.preventDefault(); 
 

 
    $('#mask').hide(); 
 
    $('.window').hide(); 
 
    }); 
 

 
    //if mask is clicked 
 
    $('#mask').click(function() { 
 
    $(this).hide(); 
 
    $('.window').hide(); 
 
    }); 
 

 
});

從執行問題