Class Browser Stay organized with collections Save and categorize content based on your preferences.
Page Summary
The Browser class in Google Apps Script provides access to dialog boxes specifically for Google Sheets.
The methods of the Browser class are only usable within the context of a Google Spreadsheet.
It is recommended to use Google Workspace dialogs instead of the Browser class methods.
The Browser class includes methods for creating input boxes and message boxes with varying parameters for prompts, titles, and button sets.
Scripts utilizing Browser methods require specific authorization scopes related to Google Sheets.
This class provides access to dialog boxes specific to Google Sheets.
The methods in this class are only available for use in the context of a Google Spreadsheet.Please useGoogle Workspace dialogs instead.
See also
Properties
| Property | Type | Description |
|---|---|---|
Buttons | Button |
Methods
| Method | Return type | Brief description |
|---|---|---|
input | String|null | Pops up a dialog box with a text input box in the user's browser. |
input | String|null | Pops up a dialog box with a text input box in the user's browser. |
input | String|null | Pops up a dialog box with a text input box in the user's browser. |
msg | String|null | Pops up a dialog box with the given message and an OK button in the user's browser. |
msg | String|null | Pops up a dialog box with the given message and specified buttons in the user's browser. |
msg | String|null | Pops up a dialog box with the given title, message and specified buttons in the user's browser. |
Detailed documentation
inputBox(prompt)
Pops up a dialog box with a text input box in the user's browser.
The inputBox method raises a client-side input box that displays the given prompt to theuser. Note that this function causes the server-side script to be suspended. It resumesautomatically after the user clears the dialog, but JDBC connections don't persist across thesuspension.
// The code below sets the value of name to the name input by the user, or// 'cancel'.constname=Browser.inputBox('Enter your name');
Parameters
| Name | Type | Description |
|---|---|---|
prompt | String | The text to be displayed in the dialog box. |
Return
String|null — The text entered by the user (or 'cancel' for a canceled or dismissed dialog).
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/spreadsheets.currentonlyhttps://www.googleapis.com/auth/spreadsheets
inputBox(prompt, buttons)
Pops up a dialog box with a text input box in the user's browser.
The inputBox method raises a client-side input box that displays the given prompt to theuser, and offers a choice of buttons to be displayed. Note that this function causes theserver-side script to be suspended. It resumes automatically after the user clears the dialog,but JDBC connections don't persist across the suspension.
// The code below sets the value of name to the name input by the user, or// 'cancel'.constname=Browser.inputBox('Enter your name',Browser.Buttons.OK_CANCEL);
Parameters
| Name | Type | Description |
|---|---|---|
prompt | String | The text to be displayed in the dialog box. |
buttons | Button | The type of button set to use. |
Return
String|null — The text entered by the user (or 'cancel' for a canceled or dismissed dialog).
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/spreadsheets.currentonlyhttps://www.googleapis.com/auth/spreadsheets
inputBox(title, prompt, buttons)
Pops up a dialog box with a text input box in the user's browser.
The inputBox method raises a client side input box with the given title, that displays thegiven prompt to the user, and offers a choice of buttons to be displayed. Note that thisfunction causes the server-side script to be suspended. It resumes automatically after the userclears the dialog, but JDBC connections don't persist across the suspension.
// The code below sets the value of name to the name input by the user, or// 'cancel'.constname=Browser.inputBox('ID Check','Enter your name',Browser.Buttons.OK_CANCEL,);
Parameters
| Name | Type | Description |
|---|---|---|
title | String | The title for the dialog box. |
prompt | String | The text to be displayed in the dialog box. |
buttons | Button | The type of button set to use. |
Return
String|null — The text entered by the user (or 'cancel' for a canceled or dismissed dialog).
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/spreadsheets.currentonlyhttps://www.googleapis.com/auth/spreadsheets
msgBox(prompt)
Pops up a dialog box with the given message and an OK button in the user's browser.
The msgBox method raises a client-side message box that displays the given message to theuser. Note that this method causes the server-side script to be suspended. It resumesautomatically after the user clears the dialog, but JDBC connections don't persist across thesuspension.
// The code below displays "hello world" in a dialog box with an OK buttonBrowser.msgBox('hello world');
Parameters
| Name | Type | Description |
|---|---|---|
prompt | String | The text to be displayed in the dialog box. |
Return
String|null — The lower case text of the button that is clicked by the user (or 'cancel' for a dismissed dialog).
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/spreadsheets.currentonlyhttps://www.googleapis.com/auth/spreadsheets
msgBox(prompt, buttons)
Pops up a dialog box with the given message and specified buttons in the user's browser.
The msgBox method raises a client-side message box that displays the given message to theuser, and offers a choice of buttons to be displayed. Note that this method causes theserver-side script to be suspended. It resumes automatically after the user clears the dialog,but JDBC connections don't persist across the suspension.
// The code below displays "hello world" in a dialog box with OK and Cancel// buttons.Browser.msgBox('hello world',Browser.Buttons.OK_CANCEL);
Parameters
| Name | Type | Description |
|---|---|---|
prompt | String | The text to be displayed in the dialog box. |
buttons | Button | The type of button set to use. |
Return
String|null — The lower case text of the button that is clicked by the user (or 'cancel' for a dismissed dialog).
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/spreadsheets.currentonlyhttps://www.googleapis.com/auth/spreadsheets
msgBox(title, prompt, buttons)
Pops up a dialog box with the given title, message and specified buttons in the user's browser.
The msgBox method raises a client-side message box with the given title, that displays thegiven message to the user, and offers a choice of buttons to be displayed. Note that thismethod causes the server-side script to be suspended. It resumes automatically after the userclears the dialog, but JDBC connections don't persist across the suspension.
// The code below displays "hello world" in a dialog box with a custom title and// Yes and No buttonsBrowser.msgBox('Greetings','hello world',Browser.Buttons.YES_NO);
Parameters
| Name | Type | Description |
|---|---|---|
title | String | The title of the dialog box. |
prompt | String | The text to be displayed in the dialog box. |
buttons | Button | The type of button set to use. |
Return
String|null — The lower case text of the button that is clicked by the user (or 'cancel' for a dismissed dialog).
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/spreadsheets.currentonlyhttps://www.googleapis.com/auth/spreadsheets
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.