Javascript provides three different dialog components to perform the operation?
1 AlertBox:- It is used to display a message to the user's
alert("message")
2 Confirm:- It is used to provide confirmation to user's and display ok and cancel button, it returns true in Ok and return false in cancel button
var s = confirm(message);
if(s)
{
}
else
{
}
3 Prompt:- It is used to display Input dialog to user's as a text field.it returns the value of the text field.
var s = prompt("message")
Complete Code of Alert, Confirm Prompt:-
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">
function funalert()
{
alert("Welcome in Alert");
}
function funconfirm()
{
s= confirm("do you want to confirm to navigate");
if(s)
{
// window.location= 'countrystatecity.html';
window.location= "http://youtube.com/shivaconceptsolution";
}
else
{
alert("CANCEL");
}
}
function funprompt()
{
name = prompt("enter name");
alert("name is "+name);
}
</script>
</head>
<body>
<button onclick="funalert()">ALERT</button>
<br>
<br>
<button onclick="funconfirm()">CONFIRM</button>
<br>
<br>
<button onclick="funprompt()">PROMPT</button>
<br>
</body>
</html>
POST Answer of Questions and ASK to Doubt