【问题标题】:Linking to another html page in Google Apps Script Not working in sandbox 'IFRAME'链接到 Google Apps 脚本中的另一个 html 页面在沙箱“IFRAME”中不起作用
【发布时间】:2015-03-19 07:27:55
【问题描述】:

在 Google Apps 脚本中:使用 NATIVE 沙盒模式:

Linking to another HTML page in Google Apps Script 工作正常。

但是当使用IFRAME沙盒模式时:

Unable to get links working in Google Apps Script when using sandbox mode of "IFRAME"

根据上面的 SO 帖子,我尝试使用 target="_blank"。正如预期的那样,当点击链接时,页面会在新窗口中打开。

然而——

在 Chrome 中使用 target="_parent" 每次都会打开一个新窗口,但 Firefox 无法正常工作。根据https://developers.google.com/apps-script/guides/html/restrictionsHTML Service 不支持target="_parent"——这可能就是它表现得像target="_blank" 的原因。

在 Chrome 和 Firefox 中使用 target="_self" 会导致第一次点击会在同一个窗口中打开,但随后的点击会显示一个空白页面。

我希望页面与我的 Apps 脚本在同一个窗口中加载,就像在不受限制的网页上的锚点中使用 target="_self" 时那样。

请帮助我。

【问题讨论】:

标签: html google-apps-script


【解决方案1】:

当使用IFRAME沙盒模式时,<a>nchors要在同一选项卡或窗口中打开,必须指定target="_top"。 2015 年下半年在 Google Apps 脚本中添加了对此的支持。在此之前出现了意外行为。来自a Google Apps Script developer blog

我们一直在努力改进 IFRAME 沙盒模式,并拥有 从那时起添加了许多功能,包括:Firefox 支持、文件 上传、顶部导航支持和改进的 Google Picker API 支持。

【讨论】:

    【解决方案2】:

    目前使用“SandBoxMode=IFRAME”时,需要通过 Google 修复文档错误。见Can't call a server function with a form with input type="file" when using SandBoxMode=IFRAME.

    我已经通过设置HtmlService.SandboxMode.NATIVE 对其进行了测试 而不是在 HtmlService.SandboxMode 设置为 Iframe 时工作。也可以参考这个相关问题here.

    【讨论】:

      猜你喜欢
      • 2013-03-18
      • 2015-07-10
      • 2021-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多