JavaScript中创建三种消息框:警告框、确认框、提示框
<1>警告框
[html]
1. <html>
2. <head>
3. <script type="text/javascript">
4. function disp_alert()
5. {
6. alert("我是警告框!!")
7. }
8. </script>
9. </head>
10. <body>
11.
12. <input type="button" onclick="disp_alert()" value="显示警告框" />
13.
14. </body>
15. </html>
<2>确认框
[html]
1. <html>
2. <head>
3. <script type="text/javascript">
4. function show_confirm()
5. {
6. var r=confirm("Press a button!");
7. if (r==true)
8. {
9. alert("You pressed OK!");
10. }
11. else
12. {
13. alert("You pressed Cancel!");
14. }
15. }
16. </script>
17. </head>
18. <body>
19.
20. <input type="button" onclick="show_confirm()" value="Show a confirm box" />
21.
22. </body>
23. </html>
<3>
[html]
1. <html>
2. <head>
3. <script type="text/javascript">
4. function disp_prompt()
5. {
6. var name=prompt("请输入您的名字","Bill Gates")
7. if (name!=null && name!="")
8. {
9. document.write("你好!" + name + " 今天过得怎么样?")
10. }
11. }
12. </script>
13. </head>
14. <body>
15.
16. <input type="button" onclick="disp_prompt()" value="显示提示框" />
17.
18. </body>
19. </html>
摘自 落日小屋
补充:web前端 , JavaScript ,