JavaScript Customizable Alert Box

Author : Tom Coote @ Innoware
Date : 15 Feb 2007
Web site : tomcoote.co.uk (for most upto date info)

This page shows an example of the alert2 message box. To use it include the css and js files on your page and call the ShowAlert2() function from an onClick event. You need to pass in the custom alert box variables;

  1. The onClick event eg this.event
  2. The title for the alert box
  3. The message for the alert box
  4. The file path to the message icon, blank for no icon
  5. An array of button values to place in the alert box eg ["OK", "Cancel"]
  6. An array of onClick events for each of the button values given above eg ['JavaScript:OKPress()','JavaScript:HideAlert2()']
  7. The width of the alert box, message text will wrap around at this width.
  8. The file path to the top right exit icon for the alert box

Click here to show an example alert box.

Example code :
<a href="#alertBox" onClick="JavaScript:ShowAlert2(event, 'Test Alert 2', 'Testing the custom JavaScript Alert Box', 'Exclamation_32x32.gif', ['OK', 'Cancel'], ['HideAlert2()','HideAlert2()'], 400, 'close.gif')" >Click here</a>

Tested in IE7, FireFox 2.0.0.1 and Opera 9.02


Feel free to use, edit or share this code as long as you credit the author in the source.