使 jQuery 模态对话框的行为类似于alert()
我通过 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" );
}
}
});
I've got a modal dialog popping up via jQuery, but I would like it to behave like a regular js alert in that a) if you are on another tab it will bring the browser's focus back to the page with the alert and b) an alert sound "ding!" will be played.
Is this possible?
Here is my dialog box:
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" );
}
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于焦点,您可以使用:
this.focus();
对于声音,请查看 SoundManager 2 Javascript 库。
在不支持 HTML5 的地方使用 Flash。
希望它有帮助!
For focus you can use:
this.focus();
For sound please take a look into SoundManager 2 Javascript's library.
Uses Flash where HTML5 is not supported.
Hope it helps!