alert() 方法用于显示带有一条指定消息和一个 确认 按钮的警告框。
alert(message)
所有主要浏览器都支持 alert() 方法
显示一个警告框:
<!DOCTYPE html> <html> <title>Web176教程(Web176.com)</title> <head> <meta charset="utf-8"> <script> function myFunction(){ alert("你好,我是一个警告框!"); } </script> </head> <body> <input type="button" >