0 votes
in JavaScript by
What are the pop-up boxes available in JavaScript?

1 Answer

0 votes
by

Below are some examples of popup boxes in javascript

  • Alert Box
  • Confirm Box
  • Prompt Box

Example of alert() in JavaScript

  1. <script type="text/javascript">  
  2. function msg(){  
  3.  alert("Hello Alert Box");  
  4. }  
  5. </script>  
  6. <input type="button" value="click" onclick="msg()"/>  

Example of confirm() in JavaScript

  1. <script type="text/javascript">  
  2. function msg(){  
  3. var vconfirm("Are u sure?");  
  4. if(v==true){  
  5. alert("ok");  
  6. }  
  7. else{  
  8. alert("cancel");  
  9. }  
  10.   
  11. }  
  12. </script>  
  13.   
  14. <input type="button" value="delete record" onclick="msg()"/>  

Example of prompt() in JavaScript

  1. <script type="text/javascript">  
  2. function msg(){  
  3. var vprompt("Who are you?");  
  4. alert("I am "+v);  
  5.   
  6. }  
  7. </script>  
  8.   
  9. <input type="button" value="click" onclick="msg()"/>  
...