Class Browser

瀏覽器

這個類別可存取 Google 試算表專用的對話方塊。

這個類別中的方法只能在 Google 試算表環境中使用。 請改用 Google Workspace 對話方塊

另請參閱

屬性

屬性類型說明
ButtonsButtonSet

方法

方法傳回類型簡短說明
inputBox(prompt)String|null在使用者瀏覽器中彈出含有文字輸入方塊的對話方塊。
inputBox(prompt, buttons)String|null在使用者瀏覽器中彈出含有文字輸入方塊的對話方塊。
inputBox(title, prompt, buttons)String|null在使用者瀏覽器中彈出含有文字輸入方塊的對話方塊。
msgBox(prompt)String|null在使用者瀏覽器中彈出對話方塊,顯示指定訊息和「確定」按鈕。
msgBox(prompt, buttons)String|null在使用者瀏覽器中彈出對話方塊,顯示指定訊息和按鈕。
msgBox(title, prompt, buttons)String|null在使用者瀏覽器中彈出對話方塊,顯示指定標題、訊息和按鈕。

內容詳盡的說明文件

inputBox(prompt)

在使用者瀏覽器中彈出含有文字輸入框的對話方塊。

inputBox 方法會顯示用戶端輸入方塊,向使用者顯示指定提示。請注意,這個函式會導致伺服器端指令碼暫停。使用者清除對話方塊後,系統會自動繼續執行,但 JDBC 連線不會在暫停期間保持連線狀態。

// The code below sets the value of name to the name input by the user, or
// 'cancel'.
const name = Browser.inputBox('Enter your name');
我們不建議使用這個方法。請改用使用者介面提示

參數

名稱類型說明
promptString對話方塊中顯示的文字。

回攻員

String|null:使用者輸入的文字 (或「cancel」,表示對話方塊已取消或關閉)。

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

inputBox(prompt, buttons)

在使用者瀏覽器中彈出含有文字輸入框的對話方塊。

inputBox 方法會顯示用戶端輸入方塊,向使用者顯示指定提示,並提供可顯示的按鈕選項。請注意,這個函式會導致伺服器端指令碼暫停。使用者清除對話方塊後,系統會自動恢復,但 JDBC 連線不會在暫停期間保持連線。

// The code below sets the value of name to the name input by the user, or
// 'cancel'.
const name = Browser.inputBox('Enter your name', Browser.Buttons.OK_CANCEL);
我們不建議使用這個方法。請改用使用者介面提示

參數

名稱類型說明
promptString對話方塊中顯示的文字。
buttonsButtonSet要使用的按鈕類型。

回攻員

String|null:使用者輸入的文字 (或「cancel」,表示對話方塊已取消或關閉)。

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

inputBox(title, prompt, buttons)

在使用者瀏覽器中彈出含有文字輸入框的對話方塊。

inputBox 方法會顯示用戶端輸入方塊,其中包含指定標題、向使用者顯示指定提示,以及提供可顯示的按鈕選項。請注意,這個函式會導致伺服器端指令碼暫停。使用者清除對話方塊後,系統會自動恢復作業,但 JDBC 連線不會在暫停期間保留。

// The code below sets the value of name to the name input by the user, or
// 'cancel'.
const name = Browser.inputBox(
    'ID Check',
    'Enter your name',
    Browser.Buttons.OK_CANCEL,
);
我們不建議使用這個方法。請改用使用者介面提示

參數

名稱類型說明
titleString對話方塊的標題。
promptString對話方塊中顯示的文字。
buttonsButtonSet要使用的按鈕類型。

回攻員

String|null:使用者輸入的文字 (或「cancel」,表示對話方塊已取消或關閉)。

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

msgBox(prompt)

在使用者瀏覽器中彈出對話方塊,顯示指定訊息和「確定」按鈕。

msgBox 方法會顯示用戶端訊息方塊,向使用者顯示指定訊息。請注意,這個方法會導致伺服器端指令碼暫停。使用者清除對話方塊後,系統會自動繼續執行,但 JDBC 連線不會在暫停期間保持連線。

// The code below displays "hello world" in a dialog box with an OK button
Browser.msgBox('hello world');
我們不建議使用這個方法。請改用 UI 警示對話方塊。

參數

名稱類型說明
promptString對話方塊中顯示的文字。

回攻員

String|null - 使用者點選的按鈕文字 (小寫),或是對話方塊遭關閉時的「取消」。

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

msgBox(prompt, buttons)

在使用者瀏覽器中彈出對話方塊,顯示指定訊息和按鈕。

msgBox 方法會引發用戶端訊息方塊,向使用者顯示指定訊息,並提供要顯示的按鈕選項。請注意,這個方法會導致伺服器端指令碼暫停。使用者清除對話方塊後,系統會自動恢復,但 JDBC 連線不會在暫停期間保持連線。

// The code below displays "hello world" in a dialog box with OK and Cancel
// buttons.
Browser.msgBox('hello world', Browser.Buttons.OK_CANCEL);
我們不建議使用這個方法。請改用 UI 警示對話方塊。

參數

名稱類型說明
promptString對話方塊中顯示的文字。
buttonsButtonSet要使用的按鈕類型。

回攻員

String|null - 使用者點選的按鈕文字 (小寫),或是對話方塊遭關閉時的「取消」。

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

msgBox(title, prompt, buttons)

在使用者瀏覽器中彈出對話方塊,顯示指定標題、訊息和按鈕。

msgBox 方法會顯示具有指定標題的用戶端訊息方塊,向使用者顯示指定訊息,並提供可供選擇的按鈕。請注意,這個方法會導致伺服器端指令碼暫停。使用者清除對話方塊後,系統會自動恢復作業,但 JDBC 連線不會在暫停期間保留。

// The code below displays "hello world" in a dialog box with a custom title and
// Yes and No buttons
Browser.msgBox('Greetings', 'hello world', Browser.Buttons.YES_NO);
我們不建議使用這個方法。請改用 UI 警示對話方塊。

參數

名稱類型說明
titleString對話方塊的標題。
promptString對話方塊中顯示的文字。
buttonsButtonSet要使用的按鈕類型。

回攻員

String|null - 使用者點選的按鈕文字 (小寫),或是對話方塊遭關閉時的「取消」。

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets