tags:

views:

77

answers:

3

How can I create a custom alert function in Javascript?

+5  A: 

You can override the existing alert function, which exists on the window object:

window.alert = function (message) {
  // Do something with message
};
Matt
+3  A: 

If you're looking for a javascript/html/css replacement, I recommend checking out jQueryUI and its implementation of modal dialogs.

advait
+2  A: 

Technically you can change what the alert function does. But, you cannot change the title or other behavior of the modal window launched by the native alert function (besides the text/content).

CD Sanchez
Alright, that's what I needed to know. +1. But accepted advait's answer because he gave me an alternate solution.
Elliot Bonneville