alert:警告框
confirm:确认框
prompt:输入框
<html> <head> <meta charset="utf-8" /> <title>各种弹出框</title> </head> <body> <button οnclick="jinggao();">警告框</button> <button οnclick="queren();">确认框</button> <button οnclick="shuru();">输入框</button> </body> <script> function jinggao() { window.alert('警告') } function queren() { var ret = window.confirm('您确定要离开吗?') // 点击确定返回true,点击取消返回false console.log(ret) } function shuru() { var ret = window.prompt('请输入您的名字', '默认值') // 点击确定返回输入内容,点击取消返回null console.log(ret) } </script> </html>