【问题标题】:Open dialog and close sidebar in Google Apps Script在 Google Apps 脚本中打开对话框并关闭边栏
【发布时间】:2015-07-08 03:18:10
【问题描述】:

我正在开发一个 Google 表格插件,并试图让脚本既关闭 HTML 侧边栏又打开一个对话框。

下面的代码不起作用,因为对话框是打开然后关闭的。

HTML 文件

google.script.run.gsSheetCreateSuccess();
google.script.host.close();

.gs 文件

function gsSheetCreateSuccess() {
var ui = SpreadsheetApp.getUi()
    ui.alert(
     'Setup Complete',
      "Success! You've Successfully completed setup on this spreadsheet.",
      ui.ButtonSet.OK)
}

下面的代码(反面)不起作用,因为 HTML 文件(侧边栏)在执行 google.script.run.gsSheetCreateSuccess(); 并打开对话框之前已关闭。

HTML 文件

google.script.host.close();
google.script.run.gsSheetCreateSuccess();

如何同时关闭侧边栏并打开对话框?

【问题讨论】:

    标签: javascript html google-apps-script


    【解决方案1】:

    使用调用gsSheetCreateSuccess()SuccessHandler()关闭侧边栏。

    google.script.run
                 .withSuccessHandler(google.script.host.close)
                 .gsSheetCreateSuccess();
    

    【讨论】:

    • 非常感谢......这节省了很多谷歌搜索时间!
    猜你喜欢
    • 2016-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多