【问题标题】:Web apps+ remotely using script使用脚本远程 Web 应用程序+
【发布时间】:2017-09-12 12:52:20
【问题描述】:

我编写了一个将文件复制到 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 服务

【问题讨论】:

  • 也许this video 会有所帮助。 here 是更多示例。
  • 是的,这正是我所需要的。我刚刚使用了 javascript 函数“google.script.run.copy(text);”其中 copy(text) 是谷歌应用脚​​本函数

标签: google-apps-script


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-20
    • 1970-01-01
    • 2011-07-17
    • 2012-08-04
    • 1970-01-01
    相关资源
    最近更新 更多