onOpen无法执行? [英] onOpen not executing?

查看:167
本文介绍了onOpen无法执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我想在每次打开Goog​​le床单时显示侧边栏.我正在使用onOpen函数并调用html页面,但未执行.当我手动运行该函数时,它可以工作,但是当打开Goog​​le工作表时它不会单独执行. 这是我的代码:

Hi guys im trying to display a sidebar on my google sheets every time it is opened. I am using the onOpen function and calling the html page, but it is not executing. When i run the function manually it works, however it doesnt execute on its own when the google sheet is opened. Here is my code:

.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>

推荐答案

Google最近(相当)限制了onOpen触发器的功能. 限制之一是无法显示侧边栏. 没有真正的解决方法,因为可安装触发器仅对创建触发器的用户有效,而对其他用户无效. 相反,每次有人打开文档时,您都会收到错误通知. 我发现最好的解决方案是创建一个可以用来打开侧边栏的按钮,这比菜单更容易实现,而且显然更明显. 该主题存在一个参考问题: https://issuetracker.google.com/issues/69238694

Google has (quite) recently restricted the functionality of onOpen triggers. One of the restrains is the impossibility to show a sidebar. There is no real workaround since installable triggers will only work for the user that created the trigger, not for the other users. Instead you will receive a error notification each time someone opens the document. The best solution I found is to create a button that one can use to open the sidebar, this is easier than a menu and obviously more visible. There is a referenced issue on that subject : https://issuetracker.google.com/issues/69238694

这篇关于onOpen无法执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆