Dialogs In Javascript #14 | Complete Javascript Tutorials |

Publié le: 01 janvier 1970
sur la chaîne: Utkarsh Gupta
16
1

In this video we have give information on the important topic which is used in the Javascript i.e "Dialogs". It is one of the Important and useful topic of the Javascript.

JavaScript uses 3 kind of dialog boxes : ALERT, PROMPT and CONFIRM. These dialog boxes can be of very much help for making our website look more attractive. ALERT BOX : An alert box is used in the website to show a warning message to the user that they have entered the wrong value other than what is required to filled in that position.

JavaScript has three kind of popup boxes: Alert box, Confirm box, and Prompt box.

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");
The window.alert() method can be written without the window prefix.

Example
alert("I am an alert box!");
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");
The window.confirm() method can be written without the window prefix.

Example
if (confirm("Press a button!")) {
txt = "You pressed OK!";
} else {
txt = "You pressed Cancel!";
}
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");
The window.prompt() method can be written without the window prefix.

Example
let person = prompt("Please enter your name", "Harry Potter");
let text;
if (person == null || person == "") {
text = "User cancelled the prompt.";
} else {
text = "Hello " + person + "! How are you today?";
}


#javascript
#javascripttutorials
#code
#coding
#css
#html
#codelife
#codeschool
#webdeveloper
#webdevelopment


Sur cette page du site, vous pouvez voir la vidéo en ligne Dialogs In Javascript #14 | Complete Javascript Tutorials | durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Utkarsh Gupta 01 janvier 1970, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 16 fois et il a aimé 1 téléspectateurs. Bon visionnage!