2012-07-05 142 views
0

我想知道如何在彈出對話框之前花多長時間?例如,當您訪問某個網站時,我想在彈出窗口顯示之前將其設置爲30秒。那可能嗎?定時jQuery UI對話框

<script type="text/javascript"> 
      $(function(){ 
       // Dialog   
       if ($.cookie('showDialog') == undefined || $.cookie('showDialog') == null || $.cookie('showDialog') != 'false') { 
       $('#dialog').dialog({ 
        autoOpen: true, 
        width: 700, 
        modal: true, 
        buttons:{ "No Thanks": function() { $(this).dialog("close"); $.cookie('showDialog', 'false'); } }, 

       }); 
       } 
       // Dialog Link 
       $('#dialog_link').click(function(){ 
        $('#dialog').dialog('open'); 
        return false; 
       }); 

       //hover states on the static widgets 
       $('#dialog_link, ul#icons li').hover(
        function() { $(this).addClass('ui-state-hover'); }, 
        function() { $(this).removeClass('ui-state-hover'); } 
       ); 

      }); 
</script> 

回答

4

您可以使用setTimeout()

setTimeout(function() { 
    $('#my-dialog').dialog('open'); 
},30000); 

jsFiddle

+0

我會在哪裏把我的現有那裏的代碼?對不起,我不是jQuery精明的... – 2012-07-05 19:50:14