Web应用程序+使用脚本远程 [英] Web apps+ remotely using script

查看:71
本文介绍了Web应用程序+使用脚本远程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I wrote a script that copies files to Google Drive. but I need to run it not from the script development page, I need to give it to the user, and I have to get from him a variable. How do I run the script remotely? If I add my script as a library to another script built into the table, then everything works, but I need the data to be passed from a google site or doGet() function.. Can I get string value and start a script from HTMLOutput?. Or any another solution of remotely starting of script(for example, pushing button on site) https://developers.google.com/apps-script/guides/web#deploying here is info about web apps, but I can't understand, how I can use it(

我也阅读了此 google apps脚本-Web应用程序似乎什么也没做. . 但"UI服务已于2014年12月11日弃用.要创建用户界面,请改用HTML服务."我不明白该使用HTML服务做什么

also i read this google apps script - web app doesn't seem to do anything . . but "The UI service was deprecated on December 11, 2014. To create user interfaces, use the HTML service instead." i can't understand what to do with this HTML service

推荐答案

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

这篇关于Web应用程序+使用脚本远程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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