Home  >  Article  >  Web Front-end  >  What are the pop-up windows in javascript?

What are the pop-up windows in javascript?

王林
王林Original
2021-07-08 14:02:133465browse

The pop-up windows in javascript include warning boxes, confirmation boxes and prompt boxes. Alert boxes are often used to ensure that users receive certain information. Confirmation boxes are often used to verify acceptance of user actions. Prompt boxes are often used to prompt users to enter a certain value before entering the page.

What are the pop-up windows in javascript?

#The operating environment of this article: windows10 system, javascript 1.8.5, thinkpad t480 computer.

There are three types of pop-up windows in JavaScript, which are warning boxes, confirmation boxes, and prompt boxes.

Let’s take a brief look at these three pop-up window types:

Alert box

Alert box is 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.

window.alert("sometext");

The window.alert() method can use the alert() method directly without the window object.

Confirmation box

Confirmation box is usually used to verify whether the user operation is accepted.

When the confirmation card pops up, the user can click "Confirm" or "Cancel" to confirm the user operation.

When you click "Confirm", the confirmation box returns true. If you click "Cancel", the confirmation box returns false.

window.confirm("sometext");

The window.confirm() method can be used directly without the window object. The confirm() method can be used directly.

Prompt box

Prompt box is often used to prompt the user 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 to confirm, the return value is the entered value. If the user clicks Cancel, the return value is null.

window.prompt("sometext","defaultvalue");

The window.prompt() method can be used directly without the window object. The prompt() method can be used directly.

Recommended related tutorials: js tutorial

The above is the detailed content of What are the pop-up windows in javascript?. For more information, please follow other related articles on the PHP Chinese website!

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