An alert box is often used if you want to give any information to the user.
Syntax :
alert(”text“);
Example:-
function popupalert()
{
alert(’This is an alert box.’);
}
Confirm box are used to make a selection for user whether he/she want to proceed further
or not.This box provide two options : ok and cancel
ok->means proceed one step further.
cancel->means reverting back to previous position
Syntax:
confirm(’text’);
Example:
<script type=”text/javascript”>
<!-
function popupconfirm()
{
confirm(’Do want to proceed.’);
}
//->
</script>
<>A prompt box is often used ,if you want the user to input a value before entering a page. This also give two option :ok and cancel
Syntax:
prompt(”text”,”defaultvalue”) ;
<script type=”text/javascript”>
<!-
function popupprompt()
{
var name=prompt(”Hello World!”,”enter name”);
document.write(name);
}
//->
</script>
<body onload=”popupprompt()”>
</body>
when you cancel prompt in above script it return display null.
