【问题标题】:Make a jQuery modal-dialog behave like an alert()使 jQuery 模态对话框的行为类似于 alert()
【发布时间】:2010-10-29 00:19:45
【问题描述】:

我通过 jQuery 弹出了一个模态对话框,但我希望它的行为类似于常规 js 警报 a) 如果您在另一个选项卡上,它将使浏览器的焦点回到带有警报的页面b) 提示音“叮!”将播放。

这可能吗?

这是我的对话框:

var $newCandleDialog = $('<div></div>')
        .load('/prodash/dash_access.php?urlInit=candles/getCanStatus.php','it='+newData)
        .dialog({
            autoOpen: false,
            title: 'Active Mode: New Candles!',
            modal: true,
            buttons: {
                "Load new candles": function() {
                    $("#canHint").load('/prodash/dash_access.php?urlInit=candles/getcandles.php','q=0&show=05&strength=00');
                    $( this ).dialog( "close" );    
                },
                Cancel: function() {
                    $( this ).dialog( "close" );
                }
            }
        });

【问题讨论】:

    标签: jquery dialog modal-dialog alert jquery-ui-dialog


    【解决方案1】:

    您可以使用:this.focus();

    有关声音,请查看SoundManager 2 Javascript's library
    在不支持 HTML5 的情况下使用 Flash。

    希望对你有帮助!

    【讨论】:

    • focus() 会在浏览器中切换你的标签页吗?
    • @user410341 取决于您的浏览器。希望不要因为没有程序会偷走你的注意力。即便如此,某些浏览器确实允许您窃取 focus()。
    猜你喜欢
    • 2012-01-30
    • 2011-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-26
    • 2011-01-22
    • 2015-05-15
    • 1970-01-01
    相关资源
    最近更新 更多