Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Sites HTML Iframe (not gadget)

I'm trying to embed a google drive folder inside my google site, but this folder will be shown only to some users. That is why I can't use Insert --> Drive --> Folder.

I found at this post stackoverflow that you can show a specift folder using a HTML Iframe and It works perfectly.

Now I'm trying to embed that iframe on my Google Site with no luck. I've tried 3 different ways:

1) Using a HTML box (Insert --> HTML box)

This return the follow: removing disallowed attribute src on tag iframe

I used the exact same html code that works just fine

<iframe src="https://drive.google.com/embeddedfolderview?id=0B9xgK9AXrIuiMS0xNTQ5MzZjNy0xYTAxLTQzMjQtYWVkOS03M2Q3YWQxMzVhN2I#list" width="800" height="600" frameborder="0"></iframe>

2) Using the HTML service (Google Apps Script)

I create a Google Script that goes like this:

Code.gs

function doGet() {
  return HtmlService.createHtmlOutputFromFile('index');
}

index.html

<html>
  <body>
    <p>Hello Stackoverflow</p>
    <iframe src="https://drive.google.com/embeddedfolderview?id=0B9xgK9AXrIuiMS0xNTQ5MzZjNy0xYTAxLTQzMjQtYWVkOS03M2Q3YWQxMzVhN2I#list" width="800" height="600" frameborder="0"></iframe>
  </body>
</html>

This only shows the "Hello stackoverflow" and space where the iframe should be.

3) Insert --> More gadgets --> Include Gadget (iframe)

This one works with the same url that I used in the other methods: https://drive.google.com/embeddedfolderview?id=0B9xgK9AXrIuiMS0xNTQ5MzZjNy0xYTAxLTQzMjQtYWVkOS03M2Q3YWQxMzVhN2I#list

But this way is useless to me because I need to have control over which users can and can't see the Google Drive folder inside the Google Site.

Notice that it has nothing to do with http or https or the shield button on Google Chrome, because I'm using a https url.

like image 467
maeq Avatar asked Oct 13 '14 11:10

maeq


People also ask

Can you iframe a Google site?

You can embed an entire webpage as an iframe in a new Google site. This will allow you to pull in content from other websites and Google tools like Apps Script, Data Studio, and App Maker, saving you the trouble of duplicating and updating that information on your page.

Can you embed HTML in Google Sites?

Add HTML, CSS, or JavaScript code to your site On a computer, open a site in new Google Sites. Embed. You can also add an embed as an entire page.

Does New Google Sites have gadgets?

Go to the Sites page that will contain the new gadget. Open the page for editing. Select Insert > More gadgets. Search for the gadget, select it from the categories on the left, or click Add gadget by URL and paste in the URL to your .


1 Answers

Try below Apps Script code

code.gs

    function doGet(e) {
    var template = HtmlService.createTemplateFromFile('Index');
    return template.evaluate()
    .setTitle('Web App Search Page')
    .setSandboxMode(HtmlService.SandboxMode.IFRAME)
    .addMetaTag('viewport', 'width=device-width, initial-scale=1')
    .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL)
}

Index.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <iframe src="https://drive.google.com/embeddedfolderview?id=XXXXXXXXXX_FOLDERID_XXXXXX#list" width="800" height="600" frameborder="0"></iframe>
  </body>
</html>

Deploy as the web app and use "exec" link

like image 95
Shivaji Avatar answered Oct 06 '22 01:10

Shivaji