【问题标题】:How to load JavaScript file after launching Google Web App启动 Google Web App 后如何加载 JavaScript 文件
【发布时间】:2020-11-18 19:28:14
【问题描述】:

我有两个问题:

  1. 我的 G-Suite 帐户中有一个 Google 网络应用程序(使用 google 应用程序脚本创建)。权限设置为执行应用程序为:我/有权访问应用程序的人:任何人

除了 Code.gs 之外,该应用还有三个文件

  1. “Form.html”(html界面)
  2. “JSfile1.html”(Javascript 例程)
  3. “JSfile2.html”(Javascript 例程)

第三个文件(“JSfile2.html”)的加载是可选的,具体取决于用户(在应用程序启动后确定)。执行 doGet(e){} 我正在加载前两个文件,根据用户我想加载或跳过“JSfile2.html”。有没有办法追加 应用启动后的 HTMLOutput。我正在使用以下代码。

   function doGet(e) {  
   var template = HtmlService.createTemplateFromFile('Form');
   var js1 = include('JSfile1')
   HTMLOutput.append(js1);
   HTMLOutput.append(template.evaluate().getContent());
   return HTMLOutput
     .setTitle('BCAS, App')
     .setSandboxMode(HtmlService.SandboxMode.IFRAME);
   }

   function include(file) {
     return HtmlService.createHtmlOutputFromFile(file).getContent();
   };
  1. 有没有办法在 Web 应用程序启动之前从用户浏览器本地存储中检索信息,并在执行 doGet() 时使其可用

【问题讨论】:

    标签: google-apps-script web-applications client-server


    【解决方案1】:

    对这两个问题都说不。正确的方法是使用google.script.run。从客户端调用服务器函数并相应地调整 DOM。

    参考:

    Client server communication

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-18
      • 1970-01-01
      • 1970-01-01
      • 2013-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-24
      相关资源
      最近更新 更多