Vasil Pavlov
Vasil Pavlov

Reputation: 91

Control Google Docs embedded viewer with JavaScript

I need to control the embedded Google Docs viewer in my site. More specifically I need to be able to enable/disable the controls for Google Slides view and to be able to start/stop the presentation with JavaScript.

I was not able to find any JavaScript API for that, nor I have been able to add my host so my JavaScript to be able to communicate with the iframe content.

Anyone did something like this?

Upvotes: 9

Views: 2396

Answers (1)

user10039288
user10039288

Reputation:

Google Docs doesn't work like that at all. Here are the steps you will need to take.

1: Create Presentation on Google Slides.
   1a: https://docs.google.com/presentation/u/0/
2: Create any scripts you want applied in the script editor.
   2a: https://developers.google.com/apps-script/guides/slides/
3: Publish Presentation. 
   3a: File>Publish to Web>Embed
4: Embed Presentation.
5: Create HTML Function call
6: Create Listener w/ Google Docs (Not on your site.)

If you want your site to be able to access and run scripts from google (Aka, disable controls.) Refer to this link below, it will show you how you can use HTML to request that a script is run from google docs. Keep in mind there is a limitation to daily function calls for free accounts w/ google. I believe it's 5500 calls per day max.

HTML Function Calls: https://developers.google.com/apps-script/guides/html/communication

You also mentioned iFrame, you can find information about that located here.

iFrame Sandboxing: https://developers.google.com/apps-script/migration/iframe

Upvotes: 0

Related Questions