3 Information Balloon (alert,prompt,confirm) common in JavaScript _javascript tips

Source: Internet
Author: User
1. Warning Prompt box
Alert ("Text").
Ex.
<ptml> <pead> <script type= "Text/javascript" > Function Disp_alert () {alert ("I am a warning box!!") "+ ' \ n ' +" Hhah ")//There is a folded line} </script> </pead> <body> <input type=" button "onclick=" Disp_alert () "Value = "Show Warning box"/> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

2. Confirm Prompt box (confirm, return True or False)
<ptml> <pead> <script type= "Text/javascript" > Function show_confirm () {var r=confirm ("Press a butt On! "); if (r==true) {alert ("You pressed ok!"); else {alert ("You pressed cancel!"); } </script> </pead> <body> <input type= "button" onclick= "Show_confirm ()" Value= "show a confirm Box "/> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

3. Prompt box (prompt returns the text of the text box)
<ptml> <pead> <script type= "Text/javascript" > function Disp_prompt () {var name=prompt ("Please enter your name", "Bill Gates") if (name!=null && name!= "") {document.write ("Hello!") "+ name +" How was your day? ")} </script> </pead> <body> <input type=" button "onclick=" Disp_prompt () "value=" Show Prompt Box "/> ; </body> </ptml>
[ctrl+a All selected note: If you need to introduce external JS need to refresh to perform]
Related Article

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.