首页 > 代码库 > HTML DOM alert() 方法
HTML DOM alert() 方法
<html> <head> <script type="text/javascript"> function disp_alert() { alert("再打个招呼。这里演示了" + "\n" + "如何在消息框中添加折行。") } </script> </head> <body> <input type="button" onclick="disp_alert()" value="http://www.mamicode.com/显示消息框" /> </body> </html>
定义和用法
alert() 方法用于显示带有一条指定消息和一个 OK 按钮的警告框。
语法
alert(message)
参数 | 描述 |
---|---|
message | 要在 window 上弹出的对话框中显示的纯文本(而非 HTML 文本) |
实例
<html> <head> <script type="text/javascript"> function display_alert() { alert("I am an alert box!!") } </script> </head> <body> <input type="button" onclick="display_alert()" value="http://www.mamicode.com/Display alert box" /> </body> </html>
TIY
显示一个对话框
显示带有折行的对话框
当所显示的对象是一个数组变量的时候,这个数组变量的元素将由逗号分隔之后一行显示出来
HTML DOM alert() 方法
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。