【问题标题】:How is it possible to display results from a google apps script as text on an html page?如何将来自谷歌应用程序脚本的结果显示为 html 页面上的文本?
【发布时间】:2015-06-27 08:09:08
【问题描述】:

我有一个谷歌应用程序脚本,我用它来读取谷歌网站的一些属性。我想在脚本小工具框中显示站点上的脚本结果。 结果只是页面名称,所以我认为它可以显示为 html 文本。有办法吗?

例如,如果我使用这样的代码:

(代码.gs)

function doGet() {
 return HtmlService.createHtmlOutputFromFile('down')
  .setSandboxMode(HtmlService.SandboxMode.NATIVE);
}

function getnames {
var list_items = SitesApp.getPageByUrl("https://sites.google.com/a/blablabla").getListItems();//got all list items here!
  Logger.log('Number of people on list: '+list_items.length+' Number of people pages: '+pages.length);

return list_items
}

(down.html)

????

我想查看网站页面上显示的 list_items 中的值。

【问题讨论】:

    标签: google-apps-script


    【解决方案1】:

    在down.html文件中放一个scriptlet:

    down.html

    <?!= getnames(); ?>
    

    你不能使用createHtmlOutputFromFile,你必须使用createTemplateFromFile

    code.gs

    function doGet() {
      var template = HtmlService.createTemplateFromFile("down");
    
      return template
        .evaluate() // evaluate MUST come before setting the sandbox mode
        .setSandboxMode(HtmlService.SandboxMode.IFRAME);
    };
    

    【讨论】:

    • 感谢您告诉我。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-05
    • 2018-03-03
    • 2017-05-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多