Dialogue Boxes In Websites

There are various types of dialog boxes or message boxes that can be used in a website. I will be providing examples of some of the most basic and frequently used ones.

Browsers by default provide two inbuilt JavaScript message boxes, "alert" and "confirm". The major drawback with these is that they cannot be styled with additional HTML controls. Also, each browser renders them differently.

You can use other third party dialog boxes that use JavaScript and CSS to render your dialog.

jQuery Dialog Box


Reference Library from where you can download it  -  http://jquery.com/download
 
Bootstrap Dialog Box


 
Reference Library from where you can download it  -  http://getbootstrap.com/getting-started/#download
 
Bootstrap Alert Box

 
 
Angular JS Dialog Box


 
Reference Library from where you can download it - https://angularjs.org/
 
Kendo UI Dialog Box

 
 
Reference Library from where you can download it - http://www.telerik.com/kendo-ui
 
There are various other available dialog boxes that can be used. Some are standalone and some come packaged along with a framework.

Example of using the above dialog boxes
  1. <h3>Different kinds of dialog boxes:</h3>  
  2. <br />  
  3. <ol>  
  4.     <li>  
  5.         <input type="button" value="Alert Box" onclick="alert('Hello');" />    
  6.         <i>Each browser renders this differently and you cannot style it</i>  
  7.         <br />  
  8.     </li>  
  9.     <li>  
  10.         <input type="button" value="Confirm" onclick="confirm('Are you sure?');" />    
  11.         <i>Provides ok and cancel buttons and return true or false. Each browser renders this differently and you cannot style it</i>  
  12.         <br />  
  13.     </li>  
  14. </ol>  
  15. <b>The below dialog boxes require third party javascript/css libraries. I will be covering the most popular ones.</b>  
  16. <ol>  
  17.     <li value="3">  
  18.         <script src="~/js/jquery-ui.min.js"></script>  
  19.         <link href="~/css/jquery-ui.min.css" rel="stylesheet" />  
  20.         <link href="~/css/jquery-ui.structure.min.css" rel="stylesheet" />  
  21.         <link href="~/css/jquery-ui.theme.min.css" rel="stylesheet" />  
  22.         <script type="text/javascript">  
  23.             $(document).ready(function () {  
  24.                 $("#dialog").dialog({  
  25.                     autoOpen: false  
  26.                 });  
  27.   
  28.                 $("#jqDialog").on("click"function () {  
  29.                     $("#dialog").dialog("open");  
  30.                 });  
  31.             });  
  32.         </script>  
  33.         <div id="dialog" title="Jquery dialog">  
  34.             <p>This is a Jquery UI dialog Box. You can customize it by adding themes.</p>  
  35.         </div>  
  36.         <input id="jqDialog" type="button" value="Jquery Dialog Box" />    
  37.         <i>Requires Jquery and Jquery UI libraries</i>  
  38.         <br />  
  39.     </li>  
  40.     <li>  
  41.         <input id="bootDialog" type="button" value="Bootstrap Dialog Box" data-toggle="modal" data-target="#myModal" />    
  42.         <i>Requires Jquery and bootstrap libraries</i>  
  43.         <!-- Modal -->  
  44.         <div class="modal fade" id="myModal" role="dialog">  
  45.             <div class="modal-dialog">  
  46.                 <!-- Modal content-->  
  47.                 <div class="modal-content">  
  48.                     <div class="modal-header">  
  49.                         <button type="button" class="close" data-dismiss="modal">×</button>  
  50.                         <h4 class="modal-title">Boostap Dialog </h4>  
  51.                     </div>  
  52.                     <div class="modal-body">  
  53.                         <p>This is a Boostrap dialog Box.</p>  
  54.                     </div>  
  55.                     <div class="modal-footer">  
  56.                         <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>  
  57.                     </div>  
  58.                 </div>  
  59.             </div>  
  60.         </div>  
  61.         <br />  
  62.     </li>  
  63.     <li>  
  64.         <script type="text/javascript">  
  65.             $(document).ready(function () {  
  66.                 $("#bootAlert").on("click"function () {  
  67.                     $("#bootAlertDiv").show();  
  68.                 });  
  69.             });  
  70.         </script>  
  71.         <input id="bootAlert" type="button" value="Bootstrap Alert" />    
  72.         <div id="bootAlertDiv" class="alert alert-success alert-dismissable fade in" style="display:none;">  
  73.             <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>  
  74.             <strong>Success!</strong> Show message to user!! Can be customized with success,info,warning and danger.  
  75.         </div>  
  76.        <i>Requires Jquery and bootstrap libraries</i>  
  77.     </li>  
  78.     <li>  
  79.         <a href="https://material.angularjs.org/latest/demo/dialog" target="_blank" class="btn-default">Angular JS Dialog</a>  
  80.         <i>Requires Angular library</i>          
  81.     </li>  
  82.     <li>         
  83.        <a href="https://demos.telerik.com/kendo-ui/dialog/index" target="_blank" class="btn-default">Kendo-ui Dialog</a>   
  84.         <i> You need to purchase license to use this library</i>  
  85.     </li>  
  86. </ol>  
Note - These examples only show how to use the dialog boxes and do not show how they should be structured.
 
I’ve also attached this example with the article so you can download it for later reference.