gpt4 book ai didi

javascript - onOpen 没有执行?

转载 作者:行者123 更新时间:2023-12-03 01:51:54 25 4
gpt4 key购买 nike

大家好,我试图在我的谷歌表格每次打开时显示一个侧边栏。我正在使用 onOpen 函数并调用 html 页面,但它没有执行。当我手动运行该函数时,它可以工作,但是当打开谷歌工作表时它不会自行执行。这是我的代码:

.gs code: 

function onOpen(){
var html = HtmlService.createHtmlOutputFromFile('tipA')
.setWidth(300);
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.showSidebar(html);
}

.html code:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div>
<p> Some text <p>
<p><img src="some link" alt="xyz" width=240 height=210></p>
</div>
</body>
</html>

最佳答案

简单的触发器打开函数无法打开侧边栏,因为它在 AuthMode.LIMITED 上运行。您应该使用在 Auth.Mode.FULL 上运行的函数来打开侧边栏,例如可安装的触发器。

我知道这与附加组件无关,但以下引用适用

来自https://developers.google.com/apps-script/add-ons/lifecycle#authorization_modes

Note: Add-ons can't open sidebars or dialogs while executing in AuthMode.LIMITED. You can use menu items to open sidebars and dialogs since these run in AuthMode.FULL.

规范的引用文献是

关于javascript - onOpen 没有执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50383296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com