如何通过Google幻灯片上的链接/按钮调用函数? [英] How to call a function via a link/button on a Google Slide?
问题描述
我希望能够通过单击Google幻灯片上的链接/按钮来发送格式化的电子邮件.一个示例场景是在会议结束后向所有员工发送反馈表,并在最后一张幻灯片上链接.
I want to be able to send a formatted email by clicking a link/button on a Google Slide. An example scenario would be sending a feedback form to all staff after a meeting, with the link on the very last slide.
我已经在Google脚本中有了电子邮件的代码,并且在运行它时可以很好地运行(我也有一个HTML格式的文件),但是我找不到通过链接/按钮运行它的方法.一张幻灯片.
I already have the code for the email in Google Script and it works perfectly fine when I run it (I also have an HTML file for the format), but I cannot find a way to run it via a link/button on a slide.
我宁愿不要每次打开幻灯片时都运行它,仅当单击特殊链接/按钮时才运行. Google脚本中有什么方法可以在幻灯片中执行此操作吗?任何帮助,方法,建议都将不胜感激!
I would rather not run it every time the slide is open, only when a special link/button is clicked. Is there a way in Google Script where I can do this in Slides? Any help, method, suggestion is greatly appreciated!
侧边栏解决方案对我有用!真不敢相信我以前没有想过,但非常感谢!
The sidebar solution works for me! Can't believe I didn't think of it before but thank you very much!
推荐答案
我已经有一段时间没有使用幻灯片了,但是我只是使用一个简单的侧边栏界面来构建它.
I haven't done anything with slides for a while but I just built this using a simple side bar interface.
function myFunction() {
var ss=SlidesApp.getActivePresentation();
var slides=ss.getSlides();
var html='<input type="button" value="Run Server Side Function" onClick="clickMe();" />';
html+='<script>function clickMe(){google.script.run.withSuccessHandler(function (time) { alert("You clicked me at " + time + ".");}).getSomeData();}</script>';
var userInterface=HtmlService.createHtmlOutput(html);
SlidesApp.getUi().showSidebar(userInterface);
}
function getSomeData() {
return Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "HH:mm:ss")
}
当然,使用html文件编写更复杂的代码要容易一些,但这只是一个快速的小演示脚本.
Of course, it's a bit easier to write more complex code using an html file but this was just a quick little demo script.
这是我的小侧边栏和按钮的外观:
Here's what my little sidebar and button look like:
很明显,在演示过程中没有出现侧栏.哦,对不起,打扰您了.
Apparently, the side bar does not show up during the presentation. Oh well, sorry to bother you.
这篇关于如何通过Google幻灯片上的链接/按钮调用函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!