使用JavaScript控制Google Docs嵌入式查看器

Vas*_*lov 7 google-docs google-slides google-slides-api

我需要在我的网站中控制嵌入式Google文档查看器.更具体地说,我需要能够启用/禁用Google幻灯片视图的控件,并能够使用JavaScript启动/停止演示.

我无法找到任何JavaScript API,也无法添加我的主机,因此我的JavaScript能够与iframe内容进行通信.

有人做过这样的事吗?

小智 -1

Google 文档根本不是这样工作的。以下是您需要采取的步骤。

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.)
Run Code Online (Sandbox Code Playgroud)

如果您希望您的网站能够访问并运行来自 google 的脚本(也称为禁用控件。)请参阅下面的此链接,它将向您展示如何使用 HTML 请求从 google 文档运行脚本。请记住,使用 google 的免费帐户的每日函数调用是有限制的。我相信每天最多 5500 个电话。

HTML 函数调用:https://developers.google.com/apps-script/guides/html/communication

您还提到了 iFrame,您可以在此处找到有关 iFrame 的信息。

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