Brief introduction of three interactive boxes (alert, confirm, prompt) of JavaScript
1. Alert box is only used to display certain information. You only need to write "alert("Hello!");" in the JavaScript tag to use it.
2. The confirm box is used to enable the user to verify or accept some 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.
Demo:
var result = confirm("Try to test the dialog!");
if (result) {
alert("You clicked OK!");
}
else {
alert("You clicked Cancel!");
}
3. Prompt is to store some information for the front page.
Demo:
var name=prompt("Please enter your name","")
if (name!=null && name!="")
{
document.write("Hello " + name + "!")
}
The above demo is written in the JavaScript tag, I didn't write it, but it's better to write a method name when you call it.