2012-07-05 153 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