开发者

Intercept and convert all alerts to notifications

开发者 https://www.devze.com 2023-03-16 06:29 出处:网络
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 a

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 开发者_StackOverflow社区body of a Gritter notification?


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
    });
};
0

精彩评论

暂无评论...
验证码 换一张
取 消