Alert Box..
An alert box is often used if you want to make sure information comes through to the user.
When an alert box pops up, the user will have to click "OK" to proceed.
Syntax: window.alert("sometext");
Confirm Box..
A confirm box is often used if you want the user to verify or accept something.
When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed.
If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.
Syntax: window.confirm("sometext");
Prompt Box..
A prompt box is often used if you want the user to input a value before entering a page.
When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value.
If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null.
Syntax:window.prompt("sometext","defaultText");
Different types of way how to define Popup Boxes in program.
CODING:An alert box is often used if you want to make sure information comes through to the user.
When an alert box pops up, the user will have to click "OK" to proceed.
Syntax: window.alert("sometext");
Confirm Box..
A confirm box is often used if you want the user to verify or accept something.
When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed.
If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.
Syntax: window.confirm("sometext");
Prompt Box..
A prompt box is often used if you want the user to input a value before entering a page.
When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value.
If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null.
Syntax:window.prompt("sometext","defaultText");
Different types of way how to define Popup Boxes in program.
<!DOCTYPE html>
<html>
<body>
<button onclick="alertDialog()">alert Dialog</button>
<button onclick="confirmDialog()">confirm Dialog</button>
<button onclick="promptDialog()">prompt Dialog</button>
<p id="demo"></p>
<script>
function alertDialog() {
alert(location.hostname+"\nDeloped By Kartik Nagar "+(99+1));
}
function confirmDialog() {
var txt;
var r = confirm("Press a button!");
if (r == true) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
}
document.getElementById("demo").innerHTML = txt;
}
function promptDialog() {
var person = prompt("Please enter your name", "Harry Potter");
if (person != null && person!="") {
document.getElementById("demo").innerHTML =
"Hello " + person + "! How are you today?";
}
else if(person==""){
document.getElementById("demo").innerHTML ="Why Clear Box";
}
else {
document.getElementById("demo").innerHTML ="Press Cancel,OK!";
}
}
</script>
</body>
</html>
<html>
<body>
<button onclick="alertDialog()">alert Dialog</button>
<button onclick="confirmDialog()">confirm Dialog</button>
<button onclick="promptDialog()">prompt Dialog</button>
<p id="demo"></p>
<script>
function alertDialog() {
alert(location.hostname+"\nDeloped By Kartik Nagar "+(99+1));
}
function confirmDialog() {
var txt;
var r = confirm("Press a button!");
if (r == true) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
}
document.getElementById("demo").innerHTML = txt;
}
function promptDialog() {
var person = prompt("Please enter your name", "Harry Potter");
if (person != null && person!="") {
document.getElementById("demo").innerHTML =
"Hello " + person + "! How are you today?";
}
else if(person==""){
document.getElementById("demo").innerHTML ="Why Clear Box";
}
else {
document.getElementById("demo").innerHTML ="Press Cancel,OK!";
}
}
</script>
</body>
</html>
Comments
Post a Comment