Tomas
Tomas

Reputation: 18117

Twitter Bootstrap style default JS alert

Is it possible to style default JS alerts using Twitter Bootstrap? For example:

alert("You can select maximum 8 files at once.");

Upvotes: 0

Views: 439

Answers (1)

James Allardice
James Allardice

Reputation: 165971

You can't style normal alert windows. Their look and feel is controlled by the OS. The best you can do is shadow the real alert function with one of your own. For example, you could override alert with a function that writes the message to console instead:

​alert = function(msg) {
    console.log(msg);  
};

alert("Hello");

In your custom alert method you could open one of Bootstrap's modal windows with the message.

Here's a working example of the above code.

Upvotes: 2

Related Questions