【问题标题】:Apps using Google Apps Script not working properly in Google Chrome version 44使用 Google Apps 脚本的应用程序在 Google Chrome 版本 44 中无法正常运行
【发布时间】:2015-07-28 03:54:38
【问题描述】:

在我工作的公司中,我们开发了很多 GAS 工具,每天用于捕获信息,以便在 QlikView 或 Google 电子表格、站点等中进行画像。但是,从上周开始,这些工具没有加载正确地,这似乎与 Google Chrome 44 版有关,因为在 43 版上运行正常。

您可以在下面找到我尝试过但仍然无法正常工作的非常简单的代码:

code.gs 文件:

function doGet(){
  var template=  HtmlService.createTemplateFromFile('transactions.html');
  var dateNew = new Date()
  var date = new Date(dateNew.getFullYear(),dateNew.getMonth(),dateNew.getDate()-1)
  template.action = ScriptApp.getService().getUrl();
  template.msg = ""
  return template.evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME);
}
function doPost(e){
  Logger.log(new Date())
  var template = HtmlService.createTemplateFromFile('transactions.html');
  template.msg = e.parameter.kpiinfo
  template.action = ScriptApp.getService().getUrl();
  return template.evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME);
}

transactions.html

<?= msg ?>
<form action="<?= action ?>" method="post">
    <td><input type="text" name="kpiinfo"></td>

    <input type="submit" value="Submit" />
</form>

当前行为:
当我加载工具时,我可以看到表单(文本框和提交按钮),然后我输入任何内容并单击提交按钮。提交的文本与文本框和提交按钮一起显示为 long(到目前为止一切都很好),但是当我单击提交时,重新加载的表单为空(既不是消息,也不是文本框,也不是提交按钮)

我尝试了不同的沙盒模式:
a) 如果我使用 Native,表单会显示,但提交按钮根本不起作用。
b) 如果我使用 Emulated 则不显示任何表单

预期行为
申请者可以连续多次提交数据。

请注意,我们有几个类似的工具,并且正在经历相同的行为。 (这些工具被大约 60 到 100 名用户使用,因此它对业务至关重要)。

如果您知道有关此问题的解决方案,我将不胜感激。提前感谢您的帮助。

【问题讨论】:

    标签: javascript html google-chrome google-apps-script


    【解决方案1】:

    我也有同样的情况。

    我用过

    .setSandboxMode(HtmlService.SandboxMode.IFRAME);
    

    而不是

    .setSandboxMode(HtmlService.SandboxMode.EMULATED)
    

    链接here。

    【讨论】:

    • 这不起作用。我使用了 IFRAME,第一次它确实正确加载了表单并允许我提交信息,但在第二次我想提交信息时,重新加载的页面是空白的。这是上周工作的,然后当谷歌浏览器升级到版本 44 时停止工作
    • 另外,我在此链接中添加了问题:code.google.com/p/google-apps-script-issues/issues/…,以防您想查看它。
    • 如果您想测试它,这是应用程序的链接script.google.com/macros/s/…
    猜你喜欢
    • 2017-06-14
    • 1970-01-01
    • 2017-11-06
    • 1970-01-01
    • 2014-02-10
    • 2018-11-11
    • 2017-12-17
    • 1970-01-01
    • 2013-10-18
    相关资源
    最近更新 更多