Home  >  Article  >  Web Front-end  >  Analysis of the difference between confirm, alert, and prompt functions in JS_javascript skills

Analysis of the difference between confirm, alert, and prompt functions in JS_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:11:401150browse

window.alert: There is only one parameter, which displays the warning box information;
No return value.
<script> <br>window.alert("OK.") <br></ script> <br>window.confirm: There is only one parameter. Display the information in the prompt box. <br>Press OK to return true; press Cancel to return false. <br><script> <br>var bln = window.confirm ("Are you sure?"); <br>alert(bln) <br></script>
window.prompt: There are two parameters,
The first parameter displays the information of the prompt input box .
The second parameter is used to display the default value of the input box.
Returns the value entered by the user.

Copy code The code is as follows:

<script> <br>var str = window.prompt("Please enter your password", "password") <br>alert(str); <br></script>
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