Sattanathan
Sattanathan

Reputation: 463

Linking to another html page in Google Apps Script Not working in sandbox 'IFRAME'

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.

Upvotes: 0

Views: 1768

Answers (2)

Jimadine
Jimadine

Reputation: 1064

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.

Upvotes: 1

Dayton Wang
Dayton Wang

Reputation: 2352

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.

Upvotes: 0

Related Questions