Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I embed a Google Docs collection in an Iframe?

I have a Google Docs collection that I would like to embed into an iframe:

https://docs.google.com/open?id=0B6yYgWS-CUJ2ZTUxZGI4MGUtMWM0Yy00YzY0LWIxOTMtMDFlN2RjNDAxNGM2

The problem here is that Google has set the X-Frame-Options header and so it seems they only allow this collection to be embedded into a Google site:

X-Frame-Options:    SAMEORIGIN

screenshot-with-shadow.png

Now I realize Google's reasons for not allowing their content in iframes some of the time, but this is one case where I feel like it would be nice to have the ability to do this.

With documents Google also allows two methods of "sharing"

  1. You can click on the "Share" button and set visibility, which will give you a link to a document
  2. Or you can click on "Publish to Web" and it will give you a link or an iframe option.

The iframe url is similar to the link URL except that it has the "&embedded=true" query variable at the end. The same thing is true for Google Maps except the parameter is "&output=embed"

Who while I believe there is nothing I can do with headers or Javascript on my site to allow the content of an iframe for a Google Docs collection to load, I was hoping someone might know of a way to generate embed code for a Google Docs collection which would allow it to be loaded in an iFrame.

like image 725
cwd Avatar asked Feb 01 '12 20:02

cwd


People also ask

Can you iframe a Google Doc?

Open your Google Document (or other Google item). Under the "File" menu, click "Publish to the Web". Copy the "iframe" code. On the page you want the Google Doc embedded, click on "Source Code" button from the WYSIWYG editor to open the HTML editor.

Can Google Docs be embedded?

You can make a document, spreadsheet, presentation, or form available to view on an existing website by embedding it in your site or blog. Open a file in Google Docs, Sheets, or Slides. Publish to web. In the window that appears, click Embed.

How do you add a Google Doc to HTML?

Copy the embed code. In your site editor, add a new "App Store & HTML" section by clicking on "Add new section" from the left panel. Mouse over the newly added section, click "Edit" and select "HTML". Paste the embed code you got from your Google Doc into the HTML box and click "Save".


1 Answers

Update: It looks like Google has allowed embedding Google Docs/Drive items via iFrame. Here are the current headers for that page (note that this URL is after the redirect):

enter image description here

like image 125
Rick Hanlon II Avatar answered Sep 22 '22 08:09

Rick Hanlon II