Home  >  Article  >  Web Front-end  >  JavaScript study notes (16) System dialog box (alert, confirm, prompt)_Basic knowledge

JavaScript study notes (16) System dialog box (alert, confirm, prompt)_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 17:52:291163browse

1. Warning box alert()

Copy code The code is as follows:

alert("Welcome !");

2. Information box confirm(), with cancel and OK buttons
Copy code The code is as follows:

if (confirm("Do you agree?")) {
alert("Agree");
} else {
alert("No Agree");
}

3. Prompt box prompt(), used to prompt the user to enter some text
Copy code The code is as follows:

var result = prompt("What is your surname?"," ");
if (result !== null) {
alert(“Welcome,” result);
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn