js脚本的alert、comfirm、prompt使用

  js脚本中可以写多种提示框,这里介绍三种,分别是alert() 警告框, confirm() 带确定与取消的提示框, prompt() 可输入文本的对话框;  (测试浏览器:搜狗高速浏览器)

 

 1 <!DOCTYPE html>
 2 <html>
 3     <head>
 4         <meta charset="UTF-8">
 5         <title></title>
 6         <script>
 7             function alertFun() {
 8                 alert("这是警告框!");
 9             }
10             
11             function confirmFun() {
12                 var flag = confirm("这是带确认取消的对话框");
13             }
14             
15             function promptFun() {
16                 prompt("这是对话框");
17             }
18             
19         </script>
20         
21     </head>
22     
23     <body background="../../img/imgBg/blueBg2.jpg"><center>
24         
25         <input type="button" value="警告框" onclick="alertFun()">
26         
27         <input type="button" value="确认框" onclick="confirmFun()">
28         
29         <input type="button" value="对话框" onclick="promptFun()">
30         
31     </body>
32     
33 </html>

  

  

  

 

posted @ 2019-07-25 21:24  a最简单  阅读(1384)  评论(0编辑  收藏  举报