Home  >  Article  >  Web Front-end  >  JS中confirm,alert,prompt函数区别分析_javascript技巧

JS中confirm,alert,prompt函数区别分析_javascript技巧

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

window.alert:参数,只有一个,显示警告框的信息;
无返回值.
<script> <BR>window.alert("确定.") <BR></script>
window.confirm : 参数就只有一个.显示提示框的信息.
按确定,返回true; 按取消返回false.
<script> <BR>var bln = window.confirm("确定吗?"); <BR>alert(bln) <BR></script>
window.prompt:参数,有两个,
第一个参数,显示提示输入框的信息.
第二个参数,用于显示输入框的默认值.
返回,用户输入的值.

复制代码 代码如下:

<script> <BR>var str = window.prompt("请输入密码","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