计时 jQuery UI 对话框

Timing jQuery UI Dialog

本文关键字:对话框 UI jQuery 计时      更新时间:2023-09-26

我想知道如何确定对话框弹出需要多长时间?例如,当您访问某个站点时,我想将其设置为弹出窗口显示前 30 秒。这可能吗?

<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>

您可以使用setTimeout() .

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

js小提琴