Popup Boxes In JavaScript: Part 1

Alert Box

 
An alert box is often used if you want to ensure information comes through to the user and it displays some information to the user.
 
Function
  1. function ShowAlert()  
  2.         {  
  3.             alert("Hello C-sharpcorner");  
  4.         } 

LineBreak Box

 
A LineBreak alert box is often used  to display line breaks inside a popup box. Use a backslash followed by the character n.
 
Function
  1. function ShowLinkBreak()  
  2.         {  
  3.             alert("Hello \n C-sharpcorner");  
  4.         } 
The following example shows how to display popup boxes in JavaScript.
 
Complete Program
 
Alert_LineBreaks_PopupDemo.html
  1. <!DOCTYPE html>  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3. <head>  
  4.     <title></title>  
  5.     <script type="text/javascript">  
  6.         function ShowAlert()  
  7.         {  
  8.             alert("Hello C-sharpcorner");  
  9.         }  
  10.         function ShowLinkBreak()  
  11.         {  
  12.             alert("Hello \n C-sharpcorner");  
  13.         }  
  14.     </script>  
  15. </head>  
  16. <body>  
  17.     <p>  
  18.         <input id="Button1" type="button" value="Show Alert Box" onclick="ShowAlert()" />    
  19.         <input id="Button2" type="button" value="Show LineBreak Box" onclick="ShowLinkBreak()" /></p>  
  20. </body>  
  21. </html> 
Output 1
 
Click on the ShowAlert button.
 
alert-box.jpg
 
Output 2
 
Click on the ShowLinkBreak button.
 
line-break-box.jpg
 
For more information, download the attached sample application.