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.
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 whenHtmlService.SandboxMode
is set toIframe
. Also reference to this related issue here.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: