在不重写多行的情况下使警报更漂亮

goo*_*ing 7 javascript jquery plugins

我知道有很多很好的插件用于漂亮的警报框,但是我已经发出了很多警报,所以我想问一下,如果不重写alert代码中的所有函数调用并用其他代替这个函数,是否可以使这些警报更漂亮?

Mat*_*all 8

你可以劫持默认window.alert函数:

window.__oldAlert__ = window.alert;
window.alert = function () {
    // your custom alert code here
};
Run Code Online (Sandbox Code Playgroud)

演示:http://jsfiddle.net/mattball/jMEha/


编辑

我需要写什么才能将其更改为此插件?http://thrivingkings.com/apprise

您的页面将需要jQuery,以及Apprise JS和CSS文件.

window.__oldAlert__ = window.alert;
window.alert = function () {
    apprise.apply(this, arguments);
};
Run Code Online (Sandbox Code Playgroud)

演示:http://jsfiddle.net/mattball/exgBs/