重写JavaScript警告jQuery的对话框
问题描述:
我试图做的魔力,把我所有的平台的JavaScript警告jQuery的对话,我也跟着下面的脚本重写JavaScript警告jQuery的对话框
<div id="overrideAlert"></div>
<script>
window.alert = function(message) {
$('#overrideAlert').text(message).dialog({
modal:true,
title:'Message',
buttons: {
'OK':function(){
$(this).dialog('close');
}
}
});
};
</script>
,但没有运气。
这是干净的解决方案吗?谢谢,
答
+0
感谢,并解决方案涵盖上弹出点击警报?说你点击一个链接,并弹出一个确认弹出窗口。我想要得到jQuery的对话框时,点击这些类型的链接 – ComeRun 2013-05-01 04:01:09
答
如果我们提交页面会自动警报之前。 一些保存成功的消息,但没有要求“好”。 我已经完成了alert.any建议的重写。 window.alert =功能(消息,回退){
$(document.createElement('div')).attr({title: 'Alert', 'class': 'alert'}).html(message).dialog({
buttons: {OK: function(){$(this).dialog('close'); callback()}},
autoOpen: true,
close:function(){$(this).remove();},
draggable: true,
modal: false,
resizable: false,
height:'auto',
width: 'auto'
});
你在控制台中的任何消息?你已经正确地将jQuery和jQuery UI加载到页面中了,是吗? – Marc 2013-05-01 02:56:15
你面临的问题是什么 – 2013-05-01 02:56:39
对我来说看起来很好http://plnkr.co/edit/mzSKFsjvkSod1oqErdFF?p=preview – 2013-05-01 02:58:19