JavaScript > JavaScript for Acrobat API Reference > JavaScript API > app > app methods > alert

alert
 
Displays an alert dialog box.
Note: If this method is called on a button click event using LiveCycle Designer 7 or 8, it appends the title "Warning: JavaScript Window - " in Acrobat 8.
Parameters
 
0 — Error (default)
1 — Warning
2 — Question
3 — Status
0 — OK (default)
1 — OK, Cancel
2 — Yes, No
3 — Yes, No, Cancel
(optional, Acrobat 6.0) If specified, a check box is created in the lower left region of the alert box. oCheckbox is a generic JavaScript object that has three properties. The first two property values are passed to the alert method; the third property returns a Boolean value.
cMsg — (optional) A string to display with the check box. If not specified, the default string is “Do not show this message again”.
bInitialValue — (optional) If true, the initial state of the check box is checked. The default is false.
bAfterValue — When the alert method exits, contains the state of the check box when the dialog box is closed. If true, the check box was checked when the alert box is closed.
Returns
nButton, the type of the button that was pressed by the user:
1 — OK
2 — Cancel
3 — No
4 — Yes
Example 1
Display a simple alert box:
	app.alert({
		cMsg: "Error! Try again!", 
		cTitle: "Acme Testing Service"
	});
Example 2
Close the document with the user’s permission:
	// A MouseUp action
	var nButton = app.alert({ 
		cMsg: "Do you want to close this document?",
		cTitle: "A message from A. C. Robat", 
		nIcon: 2, nType: 2 
	});
	if ( nButton == 4 ) this.closeDoc();
Example 3 (Acrobat 6.0)
One document creates an alert box in another document. There are two documents, DocA and DocB, one open in a browser and the other in the viewer.
	// The following is a declaration at the document level in DocA
	var myAlertBoxes = new Object;
	myAlertBoxes.oMyCheckbox = {
		cMsg: "Care to see this message again?",
		bAfterValue: false
	}
The following is a mouse-up action in DocA. The variable theOtherDoc is the Doc object of DocB. The alert box asks if the user wants to see this alert box again. If the user clicks the check box, the alert does not appear again.
	if ( !myAlertBoxes.oMyCheckbox.bAfterValue )
	{
		app.alert({
			cMsg: "This is a message from the DocA?",
			cTitle: "A message from A. C. Robat",
			oDoc:theOtherDoc, 
			oCheckbox: myAlertBoxes.oMyCheckbox
		});
	}