启动Google Web App后如何加载JavaScript文件 [英] How to load JavaScript file after launching Google Web App

查看:98
本文介绍了启动Google Web App后如何加载JavaScript文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个问题:


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

除了Code.gs,该应用程序还包含三个文件

In addition to Code.gs the app has three files


  1. Form.html (html界面)

  2. " JSfile1.html" (JavaScript例程)

  3. JSfile2.html (JavaScript例程)

根据用户的不同,第三个文件( JSfile2.html)的加载是可选的(由应用程序确定)启动)。执行doGet(e){},我正在加载前两个文件,并根据用户要加载或跳过 JSfile2.html。应用启动后,有没有一种方法可以附加
HTMLOutput。我正在使用以下代码。

The loading of the third file ("JSfile2.html") is optional depending upon the user (which is determined after the app is launched). Executing doGet(e){} I am loading the first two files and depending upon the user I would like to either load or skip "JSfile2.html". Is there a way to append HTMLOutput after the app is launched. I am using the following code.

   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 .script.run 。从客户端调用服务器功能并相应地调整DOM。

No to both questions. The proper way to do this is by using google.script.run. Call server functions from client side and adjust the DOM accordingly.

参考:

客户端服务器通信

这篇关于启动Google Web App后如何加载JavaScript文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆