Control Google Docs embedded viewer with JavaScript

穿精又带淫゛_ 提交于 2020-05-25 06:56:29

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/40786486/control-google-docs-embedded-viewer-with-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!