See also: alert, prompt

Use the confirm method to ask the user to make a decision that requires either a Yes or a No, or an OK or a Cancel.

Syntax

JSV_confirm(title, msg, icon, buttonGroup, defaultButton, modality)

Prototype

n/a

Returns

The confirm method returns true if the user chooses Yes or OK, and false if the user chooses No or Cancel.

Parameters

The confirm function uses the following arguments.

Argument Description
title A string to be displayed in the dialog title bar
msg A string to be displayed as the message to the user
icon The integer value 0 or 2 that denotes the icon to be displayed in the confirm dialog box. Default value is 2. (refer to the Message Box table)
buttonGroup The integer value 1 or 4 that denotes the button group to be displayed in the confirm dialog box. Default value is 4. (refer to the Message Box table)
defaultButton The integer value 0 or 1 that denotes the default button of the button group on the confirm dialog box. Default value is 0. (refer to the Message Box table)
modality An integer, either 0 or 1, denoting the modality of the dialog. Default value is 0. (refer to the Message Box table)

Remarks

Message Box
Argument Value Display
icon 0 No icon displayed
1
2
3
4
buttonGroup 0
1
2
3
4
5
defaultButton 0
1
2
modality 0 Application Modal. Present application (browser) is suspended until user responds.
1 System Modal. All applications (windows) are suspended until user responds.

Dependencies

n/a

Example

The following lines of code

function testConfirm() {
    var reply = JSV_confirm( "JavaScript Vision Confirmation Request", 
                             "Do you like this function?" );
    if ( reply ) alert("You replied affirmatively!");
    else alert("You replied in a negative manner!");
}

produce

Test Confirmation Dialog