Linking to another html page in Google Apps Script

2019-06-09 16:45发布

In Google Apps Script: Using NATIVE sandbox mode:

Linking to another HTML page in Google Apps Script is working fine.

But when using IFRAME sandbox mode:

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

As per the above SO post I tried using target="_blank". As expected, when the link is clicked the page opens in a new window.

However -

Using target="_parent" in Chrome opens a new window each time, but Firefox is not working. According to https://developers.google.com/apps-script/guides/html/restrictions target="_parent" is not supported by HTML Service — this is probably why it behaves like target="_blank".

Using target="_self" in both Chrome and Firefox results in the first click opening in the same window but subsequent clicks bring up a blank page.

I want the page to load in the same window as my Apps script, as would occur when using target="_self" in an anchor on an unrestricted web page.

plz help me.

2条回答
小情绪 Triste *
2楼-- · 2019-06-09 16:58

It's a doc error needs to fix with Google when using "SandBoxMode=IFRAME" currently. See Can't call a server function with a form with input type="file" when using SandBoxMode=IFRAME.

I've tested it works now by setting the HtmlService.SandboxMode.NATIVE instead of working when HtmlService.SandboxMode is set to Iframe. Also reference to this related issue here.

查看更多
何必那么认真
3楼-- · 2019-06-09 17:01

When using IFRAME sandbox mode, for <a>nchors to open in the same tab or window, target="_top" must be specified. Support for this was added to Google Apps Script in the latter half of 2015. Before this time unexpected behaviour resulted. From a Google Apps Script developer blog:

We have been working hard to improve IFRAME sandbox mode and have added many features since then, including: Firefox support, file uploads, top navigation support, and improved Google Picker API support.

查看更多
登录 后发表回答