javascript - Intercept and convert all alerts to notifications - Stack Overflow

So I'm using Gritter for notifications throughout a site, and was wondering if there was a simple

So I'm using Gritter for notifications throughout a site, and was wondering if there was a simple way to intersept all the alert() s thrown by any script, with jQuery, and reformat the value of the alert to the body of a Gritter notification?

So I'm using Gritter for notifications throughout a site, and was wondering if there was a simple way to intersept all the alert() s thrown by any script, with jQuery, and reformat the value of the alert to the body of a Gritter notification?

Share Improve this question edited Jun 28, 2011 at 6:50 stealthyninja 10.4k11 gold badges54 silver badges60 bronze badges asked Jun 28, 2011 at 5:36 user811348user811348 811 silver badge9 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

You can replace the alert function and do whatever you want with the arguments:

window.alert = function (message) {
    $.gritter.add({
        title: 'Message for you sir!',
        text: message
    });
};

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745331808a4622916.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信