【发布时间】:2021-06-05 06:22:45
【问题描述】:
我正在尝试通过单击按钮来机械化调用 docs 脚本例程(请参阅 this question)。似乎唯一的方法是为文档创建一个餐具柜。
这是我的脚本:
function CreateSideBar ()
{
Logger.log ('CreateSideBar Entry')
var HTML = HtmlService.createHtmlOutput ('<button onClick="CallFromSidebarButton () ;">Do It!</button>').setTitle ('My Sidebar') ;
DocumentApp.getUi ().showSidebar (HTML) ;
Logger.log ('CreateSideBar Exit')
}
function onOpen()
{
CreateSideBar ()
}
function CallFromSidebarButton ()
{
var ui = DocumentApp.getUi () ;
ui.alert ('Call from sidebar OK') ;
}
如果我从脚本调试器中调用它们,一切正常,但如果我打开文档,侧边栏会创建 OK,但是当我单击按钮时没有任何反应。
检验显示:
userCodeAppPanel:1 Uncaught ReferenceError: CallFromSidebarButton is not defined
at HTMLButtonElement.onclick (userCodeAppPanel:1)
该文档已共享 here。您可能需要登录并同意一堆东西。
【问题讨论】:
标签: google-apps-script web-applications google-docs