Customizing Alert boxes

I was wondering if anyone could let me know what degree of customization is possible when using alert boxes.  Can you change the colors, etc. to give it more of the look and feel of the website itself, or is it pretty much limited to the gray box?  Please let me know if you have any information (article, experience, code, etc.) about this.

Thank you!
Who is Participating?
thanassisConnect With a Mentor Commented:
JavaScript has no built in message boxes, alert, confirm and prompt are
methods of the window object. The alert box settings are 'hard-coded' into
the browser and the icon and title cannot be changed, neither can the
buttons on the confirm box, you're stuck with 'OK' and 'Cancel'
You cannot change alerts.  However, in IE, you have a little more control over a MsgBox.  You can't change the colors, etc., but at least you can choose what buttons it has and what icon it uses.

Check out:

I hope this helps!
By the way, you can do a browser check to display MsgBoxes if they have IE, otherwise you can display the traditional alerts.
You could try the following to create custom alert:

alertBgColor = 'lightblue';
alertTextColor = 'blue';
alertWindowHeight = 120;
alertWindowWidth = 350;
alertFontSize = 7;
alertFontFace = 'times';
alertTitle = 'My custom alert';


function customAlert(Message)
  w ='', '', 'dependent=yes,height='+alertWindowHeight+
  w.moveTo((parseInt(screen.width)-alertWindowWidth)/2, (parseInt(screen.height)-alertWindowHeight)/2);
  w.document.write('<html><head><title>'+alertTitle+'</title></head><body bgcolor="'+alertBgColor+'">'+
    '<font size="'+alertFontSize+'" color="'+alertTextColor+'" face="'+alertFontFace+'">'+
    Message+'</font><center><button onClick="window.close();">&nbsp;&nbsp;&nbsp;OK&nbsp;&nbsp;&nbsp;'+
<button onClick="customAlert('Hello, world!');">Allert</button>

Just change the alertBgColor, alertTextColor, alertWindowHeight, alertWindowWidth, alertFontSize, alertFontFace, alertTitle properties as you would like.

Also refer to
Oops... It seems I was too late ;)
All Courses

From novice to tech pro — start learning today.