将Javascript变量传递给Google Script函数(Google Sheets)
Pass Javascript variable to Google Script function (Google Sheets)
我有一个JavaScript函数,它正在获取src值
<div>
<img src="theUrl" id="imgID" onclick="myImageUrl()" />
</div>
<script>
function myImageUrl() {
var q = document.getElementById(imgID).src;
google.script.run
.imageCell();
}
</script>
我似乎无法弄清楚如何将其传递到 Google 应用程序函数中,以便我可以将图像 URL 实现到单元格中,例如
function imageCell() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var range = ss.getActiveRange();
range.setValue(q);
}
更新:
谢谢 Amit,但除非我错过了一些东西,否则不允许将该值用作保存的 var。我以两种方式运行它
.HTML
<div id="theImageUrl">
<img src="http://placekitten.com/100/100" id="theImageUrl" onclick="getImage()" />
</div>
<script>
function getImage() {
q = document.getElementById( 'theImageUrl ).src;
google.script.run.imageCell(q);
}
</script>
由我的小提琴小提琴验证
服务器端
function imageCell(q) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var range = ss.getActiveRange();
range.setValue(q);
}
*.setValue(q) 和 .setValue();
在 HTML 端:
google.script.run.imageCell(q);
在服务器端:
function imageCell(q) { ...
相关文章:
- Google Script HtmlService,通过多个选项卡复制URL变量
- Google Script var获取未定义的值
- 将Javascript变量传递给Google Script函数(Google Sheets)
- 在HTML下载列表中获取一个带有Selected Option的var到Google Script Spreadshee
- google.script.run.withSuccessHandler(onSuccess).onSuccess 在构
- Google script/JavaScript:这在对象后面做什么:(对象名称||{});.
- google.script.run independent usage
- ReplaceAll Google script
- Google Script-合并运算符语法在IF语句中不起作用
- 参数列表Google Script后缺少)
- 当Google Script检测到后台的更改(如cron)时,它是如何发送电子邮件的
- 编写一个Google Script来生成Google Drive的变更日志
- Google Script Invalid Assignment left-hand side
- Google-Script GetRange乘法而不是加法
- Google Script: TypeError: Cannot call method "createEve
- 仅当表单完成时才运行.google.script
- 在Google Script If语句中运行RegEx
- Google Script解析JSON -下面的路径是什么?
- Google Script '带范围的函数
- Google Script外部API访问403s“速率限制”