Interview GURU

What are the pop-up boxes available in JavaScript?

  • Alert Box
  • Confirm Box
  • Prompt Box

Example of alert() in JavaScript

<script type="text/javascript">  
function msg(){ 
alert("Hello Alert Box"); 

</script> 
<input type="button" value="click" onclick="msg()"/>

Example of confirm() in JavaScript

<script type="text/javascript">  
function msg(){ 
var v= confirm("Are u sure?"); 
if(v==true){ 
alert("ok"); 

else{ 
alert("cancel"); 

 

</script> 
 
<input type="button" value="delete record" onclick="msg()"/>

Example of prompt() in JavaScript

<script type="text/javascript">  
function msg(){ 
var v= prompt("Who are you?"); 
alert("I am "+v); 
 

</script> 
 
<input type="button" value="click" onclick="msg()"/>