网络应用+远程使用脚本

时间:2017-04-16 21:36:53

标签: google-apps-script

我写了一个将文件复制到Google云端硬盘的脚本。但我需要不是从脚本开发页面运行它,我需要将它提供给用户,我必须从他那里得到一个变量。如何远程运行脚本?如果我将我的脚本作为库添加到表中内置的另一个脚本,那么一切正常,但我需要从google站点或doGet()函数传递数据..我可以获取字符串值并从HTMLOutput启动脚本?。或任何其他远程启动脚本的解决方案(例如,在网站上按下按钮) https://developers.google.com/apps-script/guides/web#deploying 这里是关于网络应用程序的信息,但我无法理解,我如何使用它(

我也读过google apps script - web app doesn't seem to do anything . .  但是“UI服务已于2014年12月11日弃用。要创建用户界面,请改用HTML服务。”我无法理解如何处理这个HTML服务

1 个答案:

答案 0 :(得分:0)

HTML:

<body>
<input id="textField" type="text" size="4" onchange="">
<button onclick="cop()">Скопировать файлы</button>
<script>
function cop(){
var textField=document.getElementById("textField");
var text=textField.value;
google.script.run.copy(text);
//this was used for testing, it alerts what returnes from GS copy func
//google.script.run.withFailureHandler(alert).withSuccessHandler(alert).copy(text;
}
</script>
</body>

GS

function doGet(e) {
  return HtmlService.createTemplateFromFile('Copyerka').evaluate();
}

function copy(text1){
  return "Recieved year= "+text1; 
}

https://developers.google.com/apps-script/guides/html/reference/run