Three message boxes are created in JavaScript: Warning box, confirmation box, and prompt box.

Source: Internet
Author: User

<1> warning box
[Html]
1. 2. 3. <script type = "text/javascript">
4. function disp_alert ()
5 .{
6. alert ("I Am a warning box !! ")
7 .}
8. </script>
9. 10. <body>
11.
12. <input type = "button" onclick = "disp_alert ()" value = "show warning box"/>
13.
14. </body>
15.  
 
<2> confirmation box
[Html]
1. 2. 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. 18. <body>
19.
20. <input type = "button" onclick = "show_confirm ()" value = "Show a confirm box"/>
21.
22. </body>
23.  
 

 


 
<3>
[Html]
1. 2. 3. <script type = "text/javascript">
4. function disp_prompt ()
5 .{
6. var name = prompt ("enter your name", "Bill Gates ")
7. if (name! = Null & name! = "")
8 .{
9. document. write ("Hello! "+ Name +" How is today? ")
10 .}
11 .}
12. </script>
13. 14. <body>
15.
16. <input type = "button" onclick = "disp_prompt ()" value = "show prompt box"/>
17.
18. </body>
19.

 


 


From sunset hut

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.