在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无法运行。根据{{3}} target="_parent"
HTML Service
不支持 - 这可能就像target="_blank"
的行为一样。
在Chrome和Firefox中使用target="_self"
会导致同一窗口中的第一次点击打开,但后续点击会显示空白页。
我希望页面加载到与我的Apps脚本相同的窗口中,就像在不受限制的网页上的锚点中使用target="_self"
时一样。
请帮助我。
答案 0 :(得分:0)
当前使用“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.
答案 1 :(得分:0)
使用IFRAME
沙箱模式时,要在同一选项卡或窗口中打开<a>
个nchors,必须指定target="_top"
。 2015年下半年,Google Apps脚本中添加了对此的支持。在此之前,出现了意外行为。来自a Google Apps Script developer blog:
我们一直在努力改进IFRAME沙盒模式 从那时起添加了许多功能,包括:Firefox支持,文件 上传,热门导航支持,以及改进的Google Picker API 支持。