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

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.

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.

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.

Related

Embedding a google doc in a website: User comments are always anonymous in Chrome (but works in Firefox)

I am using the following code to embed google docs in my React + Asp.Net website
<iframe className="embed-responsive-item"
src={`https://docs.google.com/document/d/${props.docid}/edit?rm=minimal&embedded=true`} />
The page is displayed fine. However, in Chrome the user is always shown as Anonymous when commenting on the document although they are signed in to Google Doc accounts. In Firefox, everything works fine and users' actual account names are displayed in the comments. If I open the src link in a new tab (in Chrome), then it works fine, users can comment with their actual Google Doc account.
I wonder if there is a way to overcome this problem for embedded google docs in Chrome.
I just figured out that the comments will not be anonymous (including in Chrome) if the users (editing or accessing the document) are invited through their gmail addresses. I hope this helps others.

Chrome webview application to load extension

Is it possible to have a webview application for a web page and load extensions in the application?
I have created a frameless wrapper for one of our web pages, so we can hide the chrome header. I am also using the stylebot extension to alter some elements in the page. It works fine inside chrome, but when I run the application the stylebot extension is not loaded.
Any idea how can I add the extension to the application?
Greatly appreciate your help on this
Thanks, Laszlo
A Google chrome extension have to be load in Google Chrome (or Chromium based browsers). The Google chrome extension API is not included in the webview engine.
You can open a frameless window with create method of the Google window API. You should add an handler to browser action click and create a window of with "popup" type and the url you want. It's not exactly what you are looking for but I don't know a better way to do it on Mac. Perhaps some one more familliar with that environement could help you.
An other far more complicated solution is to fork the Crhomium project and do what you want. But it demand a large developpement I think.

Chart.js don't work when I open my app as a stand alone app in Chrome

I'm deploying my app and I have a dashboard implemented with Chart.js. When I tested my app in standard way, the dashboard works fine, but opening my app through a Google Chrome shortcut (within a window) the charts doesn't work. Just charts doesn't work in Chrome window mode.
The problem occurs in Windows 7, when I open the app directly from the shortcut, the charts doesn't work, but if I open the Google Chrome, and then open the app using the shortcut, the charts works fine.
Someone have an idea about that?
Thanks.
You'll need to look in the developer tools console to see if your getting any errors in your app. A fairly likely culprit is that you are including scripts within your html page. Chrome apps require that all scripts are external to your html and referenced using something like
<script src="path/to/your/script.js">
You'll have to do some DOM manipulation in your script file to add the charts to your page.

Google Apps Script Html Service and Internet Explorer error "This content cannot be displayed in a frame"

I am finally getting my Google script to work. It works fine in Chrome. I am using htmlservice.createHtmlOutputFromFile and the site is obviously hosted on google sites.
But when I try the page in IE, I get
This content cannot be displayed in a frame
To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame.
I tried adding in head tag
meta http-equiv="X-Frame-Options" content="allow"
but it made no difference.
Is there a javascript trick or a GAS library function I can use to try to get this to work cross browser?
Maybe your problem is related to cross domain cookies.
Check this answer maybe will work to you.

Google Drive Editor Share button is disabled when viewed in an iFrame

We've developed an integration to our application where we wrap the Google Document Editor in an iFrame so that we can edit content in context of our application. This week we've noticed that the Share button is disabled when working with Documents and Spreadsheets wrapped in the iFrame. (The Share button appears to work as normal with Presentations.) Was there an update to the document editor that would cause the share button in the edit view to be disabled when viewed through an iFrame? Is this a bug, or was this an intentional change?
Sharing button is disabled by intention due to security reasons and will not be available for iframe embeds anymore.