javascrip--Beginner (three common dialog boxes and method calls)

Source: Internet
Author: User

One.

Three common dialog boxes:

1. Must be written in <scrip></scrip>

<body><font>alert ("error") </font><br/><br/></body>

Write in body, display only text

2.

</body>alert ("error") confirm ("Do you really want to quit?") prompt ("Lose a number come in", "can only be a number Oh")

Alert ("")

Warning dialog box, function is to pop up a warning dialog box

Confirm ("")

Determines the dialog box, the function is to pop up a selection of OK dialog box, click OK to return True, point cancel return False

Prompt ("", "" ")

The function is to pop up a dialog box that allows you to enter content

Two. Method of writing and calling

Defining variables with: Var a

Define method with: function add (formal parameter) {}

Call method with: Add (argument)

<body><br/><br/><br/><input type= "button" value= "Submit" onclick= "AA ()"/></body> function  aa () {    var a=1;    A=a+A;    alert (a);} </script>

Here we define a method of AA

In body, create a new button to invoke the method AA with the button's Click event (onclick)

The output is:

Before the button is clicked:

After clicking the button:

javascrip--Beginner (three common dialog boxes and method calls)

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.