Class Browser

瀏覽器

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

這個類別中的方法僅適用於 Google 試算表。請改用 Google Workspace 對話方塊

另請參閱

屬性

屬性類型說明
ButtonsButtonSet

方法

方法傳回類型簡短說明
inputBox(prompt)String在使用者的瀏覽器中彈出對話方塊。
inputBox(prompt, buttons)String在使用者的瀏覽器中彈出對話方塊。
inputBox(title, prompt, buttons)String在使用者的瀏覽器中彈出對話方塊。
msgBox(prompt)String彈出對話方塊,提供指定訊息和使用者的瀏覽器中的 [確定] 按鈕。
msgBox(prompt, buttons)String在使用者的瀏覽器中彈出對話方塊,列出指定訊息和指定按鈕。
msgBox(title, prompt, buttons)String在使用者瀏覽器中顯示包含指定標題、訊息和指定按鈕的對話方塊。

內容詳盡的說明文件

inputBox(prompt)

在使用者的瀏覽器中彈出對話方塊。

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

// The code below sets the value of name to the name input by the user, or 'cancel'.
var name = Browser.inputBox('Enter your name');
不建議採用這個方法。請改用 UI 提示

參數

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

回攻員

String:使用者輸入的文字 (取消或關閉對話方塊則為「取消」)。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • 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'.
var name = Browser.inputBox('Enter your name', Browser.Buttons.OK_CANCEL);
不建議採用這個方法。請改用 UI 提示

參數

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

回攻員

String:使用者輸入的文字 (取消或關閉對話方塊則為「取消」)。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • 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'.
var name = Browser.inputBox('ID Check', 'Enter your name', Browser.Buttons.OK_CANCEL);
不建議採用這個方法。請改用 UI 提示

參數

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

回攻員

String:使用者輸入的文字 (取消或關閉對話方塊則為「取消」)。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • 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:使用者點選的按鈕文字 (小寫),而「cancel」(關閉) 對話方塊則為「cancel」。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • 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:使用者點選的按鈕文字 (小寫),而「cancel」(關閉) 對話方塊則為「cancel」。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • 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:使用者點選的按鈕文字 (小寫),而「cancel」(關閉) 對話方塊則為「cancel」。

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

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