Custom Alert

Custom Alert with jQuery UI.

by KevinABoucher

JavaScript

function customAlert(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: true,
        resizable: true,
        buttons: [{
            text: buttonText,
            click: function () {
                $(this).dialog("close");
                div.remove();
            }
        }]
    });
}
window.alert = customAlert;

alert("Hello, this is a custom alert!", "Test Alert");