使用 Google 应用脚本显示屏幕启动画面

Showing screen splash with Google App Script

有谁知道如何在 Google App 脚本中显示启动画面?。我想在检查电子表格的行时显示屏幕启动画面。谢谢。

在脚本编辑器中将启动画面创建为 HTML 文件。在文件->新建 select Html 文件下。调用文件 test_HTML 并将其放入文件中:

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    Splash
  </body>
  <script>

  setTimeout(myFunction, 3000)

  function myFunction() {
    google.script.host.close();
  }
  </script>
</html>

在 Code.gs 中放置以下内容:

function onEdit(e){

  var splashScreen = HtmlService.createHtmlOutputFromFile('test_HTML')
        .setHeight(600)
        .setWidth(600);

  SpreadsheetApp.getUi()
      .showModalDialog(splashScreen, 'Dialog title');

}

在这种情况下,编辑文档时,启动画面 HTML 将弹出并显示 3 秒。您必须修改它才能使用您的代码,但应该向您提供使用 HTML 服务作为初始屏幕的基本原则。