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>

  

  

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM