Home >Web Front-end >JS Tutorial >How to use javascript dialog box (alert box, javascript confirmation box, prompt box)_Basic knowledge

How to use javascript dialog box (alert box, javascript confirmation box, prompt box)_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 17:05:071577browse

1. Warning box

Alert boxes are often used to ensure that users can get certain information.

When the warning box appears, the user needs to click the OK button to continue the operation.

Syntax:

Copy code The code is as follows:

alert("text")

2. Confirmation box

Confirmation boxes are used to allow users to verify or accept certain information.

When the confirmation box appears, the user needs to click the OK or Cancel button to continue the operation.

If the user clicks Confirm, the return value is true. If the user clicks Cancel, the return value is false.

Syntax:

Copy code The code is as follows:

confirm("text")

3. Prompt box

Prompt boxes are often used to prompt users to enter a certain value before entering the page.

When the prompt box appears, the user needs to enter a certain value and then click the confirm or cancel button to continue the operation.

If the user clicks Confirm, the return value is the entered value. If the user clicks Cancel, the return value is null.

Syntax:

Copy code The code is as follows:

prompt("text"," Default value")

Example:

Copy code The code is as follows:






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