Message box with buttons

Here is how to show a message box with buttons.

Source Code

Here is source code.

function myFunction() {
  Browser.msgBox("Open Google?", Browser.Buttons.OK_CANCEL);
}

Here is refactored source code.

function myFunction() {
  var msg = "Open Google?";
  Browser.msgBox(msg, Browser.Buttons.OK_CANCEL);
}

Format

Browser.msgBox(text, buttons)

Parameters

(1) text

You have to edit text to be shown on a message box.

(2) buttons

You have to edit a type of buttons to be shown. Here is all parameters for “buttons”

ParametersMeanings
Browser.Buttons.OKOK
Browser.Buttons.OK_CANCEL OK, Cancel
Browser.Buttons.YES_NOYes, No
Browser.Buttons.YES_NO_CANCEL Yes, No, Cancel

Returns

ButtonsReturns
OKok
Cancelcancel
Yesyes
Nono

Note

It is unable to use in Google Sites.

2 thoughts on “Message box with buttons”

Leave a Comment