Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 18:11:40
Original
1099 people have browsed it

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>
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!