JavaScript pop-up window code format and instructions for use

Source: Internet
Author: User
Tags close page

The javascript dialog box for the tutorial "(www.bkjia.com)" has the following forms:

1. alert ()
2. confirm ()
3. directly call window. event. returnValue to bring up the dialog box.
4. prompt ()

I. alert
In the alert dialog box, only one confirm button is used. For example:


Usage:

Reference content is as follows:
Function funShowAlert ()
{
Alert ("only OK! ");
}

Ii. confirm
The confirm dialog box contains the "OK" and "cancel" buttons. For example:

Usage:

Reference content is as follows:
Function funShowConfirm ()
{
If (window. confirm ("confirm dialog box "))
{
Alert ("You selected OK ");
}
Else
{
Alert ("you have chosen to cancel ");
}
}


3. directly call the window. event. returnValue pop-up dialog box. The dialog box also contains the "OK" and "cancel" buttons, but the icons in the dialog box are exclamation points, such:


For example, when we close the page, the close page dialog box is displayed. The Code is as follows:

Reference content is as follows:
<Body onbeforeunload = "window. event. returnValue = 'Dialog box with exclamation marks- (www.bkjia.com) '"> </body>

4. prompt is a dialog box with an input box. It is not described here.

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.