The javascript dialog box USES the method of of warning box javascript confirmation box prompt box

  • 2020-03-30 01:15:22
  • OfStack

1. The alert box

Warning boxes are often used to ensure that certain information is available to the user.

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

Grammar:


alert(" The text ")

2. Confirmation box

The confirmation box is used to allow the user to verify or accept certain information.

When the confirmation box appears, the user needs to click ok or cancel button to continue the operation.

If the user clicks ok, the return value is true. If the user clicks cancel, the return value is false.

Grammar:


confirm(" The text ")

3. Prompt dialog box

The prompt box is often used to prompt the user to enter a value before entering the page.

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

If the user clicks ok, the return value is the value entered. If the user clicks cancel, the return value is null.

Grammar:


prompt(" The text "," The default value ")

Example:


<html>
<body>
<script type="text/javascript">
var option=confirm("choose the option?");//true,false
alert(option);
var poption=prompt("right,this?");//null or other
alert(poption);
</script>
</body>
</html>


Related articles: