JavaScript popups (alerts, confirmations, prompts)

JavaScript has three types of popup boxes: alert boxes, confirmation boxes, and prompt boxes.

1. Warning box

Alert boxes are often used if you want to ensure that information is passed on to the user. When the alert box pops up, the user will need to click OK to continue

basic statement

 < script > //警告框window . alert ( "成功弹出警告框!" ) ; //window.alert()方法可以不带window前缀。 //alert("成功弹出警告框!") < / script >

show result

insert image description here

2. Confirmation box

A Confirmation box is usually used if you want the user to authenticate or accept something. When the confirmation box pops up, the user will have to click “OK” or “Cancel” to proceed.

basic statement

 < script > //确认框//原理:如果用户单击“确定”,该框返回true。如果用户单击“取消”,该框返回false。 window . confirm ( "请选择确定

The post JavaScript Popups (Alerts, Confirms, Prompts) first appeared on Lenix Blog .

This article is reprinted from https://blog.p2hp.com/archives/9158
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment

Your email address will not be published.