警告框:alert(警告信息)
确认框:conifrm(提示信息)
输入框:prompt(提示信息)
1 <html> 2 <head> 3 <meta charset="utf-8" /> 4 <title>几个弹出框</title> 5 </head> 6 <body> 7 <button onclick="jinggao();">警告框</button> 8 <button onclick="queren();">确认框</button> 9 <button onclick="shuru();">输入框</button>10 </body>11 <script>12 function jinggao()13 {14 // alert(‘警告‘)15 window.alert(‘警告‘)16 }17 function queren()18 {19 var ret = window.confirm(‘您确定要删库跑路吗?‘)20 // 点击确定返回true,点击取消返回false21 console.log(ret)22 }23 function shuru()24 {25 var ret = window.prompt(‘请输入您要删除的用户名:‘, ‘默认值‘)26 // 返回的内容就是输入框中输入的内容,点击取消返回null27 console.log(ret)28 }29 </script>30 </html>
window.函数:表明这个函数属于window,可省略