google-apps-script - Refresh Client Side Web Page
问题描述
I created a google web app that gets information from a google spreadsheet. If I have the web app opened in a browser, then go make a change in the spreadsheet, within the webpage, can I display some text that the page needs to be refreshed?
解决方案
一个简单的轮询示例:
只需复制代码并运行开始轮询。单击开始轮询按钮。更改活动工作表的 A1 中的值并观察侧边栏。
function startPolling() {
var html='<div id="msg"></div><input type="button" value="Start Polling" onClick="startPolling();" />';
html+='<script>function startPolling(){setInterval(getA1,5000);}function getA1(){google.script.run.withSuccessHandler(function(hl){document.getElementById(\'msg\').innerHTML=hl;}).getA1();}</script>';
var userInterface=HtmlService.createHtmlOutput(html);
SpreadsheetApp.getUi().showSidebar(userInterface);
}
function getA1() {
//SpreadsheetApp.getActive().toast('Polling');//helpful for debugging
return SpreadsheetApp.getActiveSheet().getRange('A1').getValue();
}
推荐阅读
- java - getContextPath() 在不同的环境中表现不同
- uwp - 如何更改禁用的 UWP ComboBox 的前景色?
- java - 在 TextView 上使用 setOnTouchListerner 时 autoLink="web" 不起作用
- mysql - 将数据从另一个表(从另一个连接)插入到表中
- python - Python:如何在 tkinter 的检查按钮中动态分配变量
- shell - 如何通过 impala shell 脚本显示任何消息
- algorithm - 如何从不接近的 U(a,b) 中抽取 n 个样本?
- python - 公网IP无法访问服务器机器上的scrapyd接口
- react-native - 上下文 API React Native
- javascript - 为什么 id 和 itemId 在该反应代码中从不匹配?