警告框: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,點擊取消返回false 21 console.log(ret) 22 } 23 function shuru() 24 { 25 var ret = window.prompt('請輸入您要刪除的用戶名:', '默認值') 26 // 返回的內容就是輸入框中輸入的內容,點擊取消返回null 27 console.log(ret) 28 } 29 </script> 30 </html>
window.函數:表明這個函數屬於window,可省略