: Use alert to prompt information, and will eventually be converted into string output (because toString is called). For example, the result of alert (1+1) popping should be "2" in the form of a string.
: Added selective actions for users on the basis of alert (providing two buttons: OK and Cancel)
for example:var delin = confirm('Are you sure you want to delete it?');
In this sentence, when the user clicks the OK button, the result we accept is true, and when the cancel button is clicked, the result we accept is false. After that, we can do different processing according to different results.
: Add the effect of user input based on confirm
For example, var flag = prompt('Please enter the comments you want to feedback:');
When the user clicks the Cancel button, the result we get is null; if the user clicks the OK button, the content we get is entered by the user. (If the user does not enter anything, the result obtained is an empty string)
//But in real projects, especially in websites that require beautiful styles, our prompt boxes are generally implemented by encapsulating plugins and components themselves, and these built-in methods are not used (using native JS to encapsulate modal box components)
Summarize
The above are the three pop-up boxes of JS browser introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time!