Mat*_*att 30
您可以覆盖对象alert上存在的现有函数window:
window.alert = function (message) {
// Do something with message
};
Run Code Online (Sandbox Code Playgroud)
Wal*_*osz 15
这是我提出的解决方案.我写了一个通用函数来创建一个jQueryUI对话框.如果需要,可以使用Matt的建议覆盖默认警报功能:window.alert = alert2;
// Generic self-contained jQueryUI alternative to
// the browser's default JavaScript alert method.
// The only prerequisite is to include jQuery & jQueryUI
// This method automatically creates/destroys the container div
// params:
// message = message to display
// title = the title to display on the alert
// buttonText = the text to display on the button which closes the alert
function alert2(message, title, buttonText) {
buttonText = (buttonText == undefined) ? "Ok" : buttonText;
title = (title == undefined) ? "The page says:" : title;
var div = $('<div>');
div.html(message);
div.attr('title', title);
div.dialog({
autoOpen: true,
modal: true,
draggable: false,
resizable: false,
buttons: [{
text: buttonText,
click: function () {
$(this).dialog("close");
div.remove();
}
}]
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
44743 次 |
| 最近记录: |