如何解决Google表格附加边栏点击事件不适用于某些用户
Google表格附加边栏问题
单击侧栏中的菜单项时,不会触发Code.gs中存在的应用程序脚本功能。 google.script.run.withSuccessHandler().withFailureHandler().generateContract();
--->对某些用户不起作用。
Code.gs
function onOpen() {
SpreadsheetApp.getUi().createAddonMenu().addItem('Sidebar','showSidebar').addToUi();
}
function generateContract() {
var ui = SpreadsheetApp.getUi();
ui.alert("Hello there! You're in the generateContract Function.");
return;
}
function showSidebar() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Data");
var ui = SpreadsheetApp.getUi();
var emailID = Session.getEffectiveUser().getEmail();
var html= HtmlService.createHtmlOutputFromFile('sidebar').setTitle("Sidebar");
ui.showSidebar(html);
}
警报“您好!您在generateContract函数中。” 不会被某些用户触发。不知道为什么。
sidebar.html
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@200;300;400;500;600;700&display=swap" rel="stylesheet">
<base target="_top">
<script>
function generatecontracts() {
document.getElementById("generate-contracts").classList.toggle("show");
}
function GenerateContract() {
google.script.run.withSuccessHandler().withFailureHandler().generateContract();
}
</script>
</head>
<body style="margin: 0px; overflow: hidden">
<div class="dropdown">
<div class="d-flex">
<button onclick=generatecontracts() class="dropbtn db-txt">
Generate Contracts
</button>
<button onclick=generatecontracts() class="arrow">▼</button>
</div>
<div class="dropdown-content" id="generate-contracts">
<button class="drop-btn" onClick='GenerateContract()'>Generate Contract</button>
</div>
</div>
</body>
</html>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。