在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/restrictions target="_parent"
不支持 HTML Service
- 这可能就像 target="_blank"
的行为一样 .
在Chrome和Firefox中使用 target="_self"
会导致同一窗口中的第一次点击打开,但后续点击会显示空白页面 .
我希望页面加载到与我的Apps脚本相同的窗口中,就像在不受限制的网页上的锚点中使用 target="_self"
时那样 .
请帮助我 .
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.使用
IFRAME
沙箱模式时,要在同一选项卡或窗口中打开<a>
nchors,必须指定target="_top"
. 2015年下半年,Google Apps脚本中添加了对此的支持 . 在此之前,出现了意外行为 . 来自a Google Apps Script developer blog: